chore(pre-commit): Add pyupgrade and pycln hooks (#24197)

This commit is contained in:
John Bodley
2023-06-01 12:01:10 -07:00
committed by GitHub
parent 7d7ce63970
commit a4d5d7c6b9
448 changed files with 3084 additions and 3305 deletions

View File

@@ -16,7 +16,7 @@
# under the License.
import json
import os
from typing import Any, Callable, Dict, List, Optional
from typing import Any, Callable, Optional
import celery
from cachelib.base import BaseCache
@@ -58,7 +58,7 @@ class ResultsBackendManager:
class UIManifestProcessor:
def __init__(self, app_dir: str) -> None:
self.app: Optional[Flask] = None
self.manifest: Dict[str, Dict[str, List[str]]] = {}
self.manifest: dict[str, dict[str, list[str]]] = {}
self.manifest_file = f"{app_dir}/static/assets/manifest.json"
def init_app(self, app: Flask) -> None:
@@ -70,10 +70,10 @@ class UIManifestProcessor:
def register_processor(self, app: Flask) -> None:
app.template_context_processors[None].append(self.get_manifest)
def get_manifest(self) -> Dict[str, Callable[[str], List[str]]]:
def get_manifest(self) -> dict[str, Callable[[str], list[str]]]:
loaded_chunks = set()
def get_files(bundle: str, asset_type: str = "js") -> List[str]:
def get_files(bundle: str, asset_type: str = "js") -> list[str]:
files = self.get_manifest_files(bundle, asset_type)
filtered_files = [f for f in files if f not in loaded_chunks]
for f in filtered_files:
@@ -88,7 +88,7 @@ class UIManifestProcessor:
def parse_manifest_json(self) -> None:
try:
with open(self.manifest_file, "r") as f:
with open(self.manifest_file) as f:
# the manifest includes non-entry files we only need entries in
# templates
full_manifest = json.load(f)
@@ -96,7 +96,7 @@ class UIManifestProcessor:
except Exception: # pylint: disable=broad-except
pass
def get_manifest_files(self, bundle: str, asset_type: str) -> List[str]:
def get_manifest_files(self, bundle: str, asset_type: str) -> list[str]:
if self.app and self.app.debug:
self.parse_manifest_json()
return self.manifest.get(bundle, {}).get(asset_type, [])
@@ -117,7 +117,7 @@ cache_manager = CacheManager()
celery_app = celery.Celery()
csrf = CSRFProtect()
db = SQLA()
_event_logger: Dict[str, Any] = {}
_event_logger: dict[str, Any] = {}
encrypted_field_factory = EncryptedFieldFactory()
event_logger = LocalProxy(lambda: _event_logger.get("event_logger"))
feature_flag_manager = FeatureFlagManager()

View File

@@ -16,7 +16,7 @@
# under the License.
from datetime import datetime, timedelta
from typing import Any, Dict, List, Optional
from typing import Any, Optional
from uuid import UUID, uuid3
from flask import Flask
@@ -37,7 +37,7 @@ class SupersetMetastoreCache(BaseCache):
@classmethod
def factory(
cls, app: Flask, config: Dict[str, Any], args: List[Any], kwargs: Dict[str, Any]
cls, app: Flask, config: dict[str, Any], args: list[Any], kwargs: dict[str, Any]
) -> BaseCache:
seed = config.get("CACHE_KEY_PREFIX", "")
kwargs["namespace"] = get_uuid_namespace(seed)