mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
chore(pre-commit): Add pyupgrade and pycln hooks (#24197)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any, ClassVar, Dict, List, Optional, TYPE_CHECKING, Union
|
||||
from typing import Any, ClassVar, TYPE_CHECKING
|
||||
|
||||
import pandas as pd
|
||||
|
||||
@@ -47,15 +47,15 @@ class QueryContext:
|
||||
enforce_numerical_metrics: ClassVar[bool] = True
|
||||
|
||||
datasource: BaseDatasource
|
||||
slice_: Optional[Slice] = None
|
||||
queries: List[QueryObject]
|
||||
form_data: Optional[Dict[str, Any]]
|
||||
slice_: Slice | None = None
|
||||
queries: list[QueryObject]
|
||||
form_data: dict[str, Any] | None
|
||||
result_type: ChartDataResultType
|
||||
result_format: ChartDataResultFormat
|
||||
force: bool
|
||||
custom_cache_timeout: Optional[int]
|
||||
custom_cache_timeout: int | None
|
||||
|
||||
cache_values: Dict[str, Any]
|
||||
cache_values: dict[str, Any]
|
||||
|
||||
_processor: QueryContextProcessor
|
||||
|
||||
@@ -65,14 +65,14 @@ class QueryContext:
|
||||
self,
|
||||
*,
|
||||
datasource: BaseDatasource,
|
||||
queries: List[QueryObject],
|
||||
slice_: Optional[Slice],
|
||||
form_data: Optional[Dict[str, Any]],
|
||||
queries: list[QueryObject],
|
||||
slice_: Slice | None,
|
||||
form_data: dict[str, Any] | None,
|
||||
result_type: ChartDataResultType,
|
||||
result_format: ChartDataResultFormat,
|
||||
force: bool = False,
|
||||
custom_cache_timeout: Optional[int] = None,
|
||||
cache_values: Dict[str, Any],
|
||||
custom_cache_timeout: int | None = None,
|
||||
cache_values: dict[str, Any],
|
||||
) -> None:
|
||||
self.datasource = datasource
|
||||
self.slice_ = slice_
|
||||
@@ -88,18 +88,18 @@ class QueryContext:
|
||||
def get_data(
|
||||
self,
|
||||
df: pd.DataFrame,
|
||||
) -> Union[str, List[Dict[str, Any]]]:
|
||||
) -> str | list[dict[str, Any]]:
|
||||
return self._processor.get_data(df)
|
||||
|
||||
def get_payload(
|
||||
self,
|
||||
cache_query_context: Optional[bool] = False,
|
||||
cache_query_context: bool | None = False,
|
||||
force_cached: bool = False,
|
||||
) -> Dict[str, Any]:
|
||||
) -> dict[str, Any]:
|
||||
"""Returns the query results with both metadata and data"""
|
||||
return self._processor.get_payload(cache_query_context, force_cached)
|
||||
|
||||
def get_cache_timeout(self) -> Optional[int]:
|
||||
def get_cache_timeout(self) -> int | None:
|
||||
if self.custom_cache_timeout is not None:
|
||||
return self.custom_cache_timeout
|
||||
if self.slice_ and self.slice_.cache_timeout is not None:
|
||||
@@ -110,14 +110,14 @@ class QueryContext:
|
||||
return self.datasource.database.cache_timeout
|
||||
return None
|
||||
|
||||
def query_cache_key(self, query_obj: QueryObject, **kwargs: Any) -> Optional[str]:
|
||||
def query_cache_key(self, query_obj: QueryObject, **kwargs: Any) -> str | None:
|
||||
return self._processor.query_cache_key(query_obj, **kwargs)
|
||||
|
||||
def get_df_payload(
|
||||
self,
|
||||
query_obj: QueryObject,
|
||||
force_cached: Optional[bool] = False,
|
||||
) -> Dict[str, Any]:
|
||||
force_cached: bool | None = False,
|
||||
) -> dict[str, Any]:
|
||||
return self._processor.get_df_payload(
|
||||
query_obj=query_obj,
|
||||
force_cached=force_cached,
|
||||
|
||||
Reference in New Issue
Block a user