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

@@ -17,7 +17,7 @@
from __future__ import annotations
import logging
from typing import Any, Dict, List, Optional
from typing import Any
from flask_caching import Cache
from pandas import DataFrame
@@ -37,7 +37,7 @@ config = app.config
stats_logger: BaseStatsLogger = config["STATS_LOGGER"]
logger = logging.getLogger(__name__)
_cache: Dict[CacheRegion, Cache] = {
_cache: dict[CacheRegion, Cache] = {
CacheRegion.DEFAULT: cache_manager.cache,
CacheRegion.DATA: cache_manager.data_cache,
}
@@ -53,17 +53,17 @@ class QueryCacheManager:
self,
df: DataFrame = DataFrame(),
query: str = "",
annotation_data: Optional[Dict[str, Any]] = None,
applied_template_filters: Optional[List[str]] = None,
applied_filter_columns: Optional[List[Column]] = None,
rejected_filter_columns: Optional[List[Column]] = None,
status: Optional[str] = None,
error_message: Optional[str] = None,
annotation_data: dict[str, Any] | None = None,
applied_template_filters: list[str] | None = None,
applied_filter_columns: list[Column] | None = None,
rejected_filter_columns: list[Column] | None = None,
status: str | None = None,
error_message: str | None = None,
is_loaded: bool = False,
stacktrace: Optional[str] = None,
is_cached: Optional[bool] = None,
cache_dttm: Optional[str] = None,
cache_value: Optional[Dict[str, Any]] = None,
stacktrace: str | None = None,
is_cached: bool | None = None,
cache_dttm: str | None = None,
cache_value: dict[str, Any] | None = None,
) -> None:
self.df = df
self.query = query
@@ -85,10 +85,10 @@ class QueryCacheManager:
self,
key: str,
query_result: QueryResult,
annotation_data: Optional[Dict[str, Any]] = None,
force_query: Optional[bool] = False,
timeout: Optional[int] = None,
datasource_uid: Optional[str] = None,
annotation_data: dict[str, Any] | None = None,
force_query: bool | None = False,
timeout: int | None = None,
datasource_uid: str | None = None,
region: CacheRegion = CacheRegion.DEFAULT,
) -> None:
"""
@@ -136,11 +136,11 @@ class QueryCacheManager:
@classmethod
def get(
cls,
key: Optional[str],
key: str | None,
region: CacheRegion = CacheRegion.DEFAULT,
force_query: Optional[bool] = False,
force_cached: Optional[bool] = False,
) -> "QueryCacheManager":
force_query: bool | None = False,
force_cached: bool | None = False,
) -> QueryCacheManager:
"""
Initialize QueryCacheManager by query-cache key
"""
@@ -190,10 +190,10 @@ class QueryCacheManager:
@staticmethod
def set(
key: Optional[str],
value: Dict[str, Any],
timeout: Optional[int] = None,
datasource_uid: Optional[str] = None,
key: str | None,
value: dict[str, Any],
timeout: int | None = None,
datasource_uid: str | None = None,
region: CacheRegion = CacheRegion.DEFAULT,
) -> None:
"""
@@ -204,7 +204,7 @@ class QueryCacheManager:
@staticmethod
def delete(
key: Optional[str],
key: str | None,
region: CacheRegion = CacheRegion.DEFAULT,
) -> None:
if key:
@@ -212,7 +212,7 @@ class QueryCacheManager:
@staticmethod
def has(
key: Optional[str],
key: str | None,
region: CacheRegion = CacheRegion.DEFAULT,
) -> bool:
return bool(_cache[region].get(key)) if key else False