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:
@@ -29,7 +29,7 @@ from inspect import (
|
||||
Signature,
|
||||
)
|
||||
from logging import Logger
|
||||
from typing import Any, Callable, cast, Optional, Type, Union
|
||||
from typing import Any, Callable, cast, Union
|
||||
|
||||
_DEFAULT_ENTER_MSG_PREFIX = "enter to "
|
||||
_DEFAULT_ENTER_MSG_SUFFIX = ""
|
||||
@@ -48,11 +48,11 @@ empty_and_none = {Signature.empty, "None"}
|
||||
|
||||
|
||||
Function = Callable[..., Any]
|
||||
Decorated = Union[Type[Any], Function]
|
||||
Decorated = Union[type[Any], Function]
|
||||
|
||||
|
||||
def log(
|
||||
decorated: Optional[Decorated] = None,
|
||||
decorated: Decorated | None = None,
|
||||
*,
|
||||
prefix_enter_msg: str = _DEFAULT_ENTER_MSG_PREFIX,
|
||||
suffix_enter_msg: str = _DEFAULT_ENTER_MSG_SUFFIX,
|
||||
@@ -85,11 +85,11 @@ def _make_decorator(
|
||||
def decorator(decorated: Decorated):
|
||||
decorated_logger = _get_logger(decorated)
|
||||
|
||||
def decorator_class(clazz: Type[Any]) -> Type[Any]:
|
||||
def decorator_class(clazz: type[Any]) -> type[Any]:
|
||||
_decorate_class_members_with_logs(clazz)
|
||||
return clazz
|
||||
|
||||
def _decorate_class_members_with_logs(clazz: Type[Any]) -> None:
|
||||
def _decorate_class_members_with_logs(clazz: type[Any]) -> None:
|
||||
members = getmembers(
|
||||
clazz, predicate=lambda val: ismethod(val) or isfunction(val)
|
||||
)
|
||||
@@ -160,7 +160,7 @@ def _make_decorator(
|
||||
return _wrapper_func
|
||||
|
||||
if isclass(decorated):
|
||||
return decorator_class(cast(Type[Any], decorated))
|
||||
return decorator_class(cast(type[Any], decorated))
|
||||
return decorator_func(cast(Function, decorated))
|
||||
|
||||
return decorator
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# under the License.
|
||||
import copy
|
||||
import dataclasses
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from superset.common.chart_data import ChartDataResultType
|
||||
from superset.utils.core import AnnotationType, DTTM_ALIAS
|
||||
@@ -42,7 +42,7 @@ query_birth_names = {
|
||||
"where": "",
|
||||
}
|
||||
|
||||
QUERY_OBJECTS: Dict[str, Dict[str, object]] = {
|
||||
QUERY_OBJECTS: dict[str, dict[str, object]] = {
|
||||
"birth_names": query_birth_names,
|
||||
# `:suffix` are overrides only
|
||||
"birth_names:include_time": {
|
||||
@@ -205,7 +205,7 @@ def get_query_object(
|
||||
query_name: str,
|
||||
add_postprocessing_operations: bool,
|
||||
add_time_offsets: bool,
|
||||
) -> Dict[str, Any]:
|
||||
) -> dict[str, Any]:
|
||||
if query_name not in QUERY_OBJECTS:
|
||||
raise Exception(f"QueryObject fixture not defined for datasource: {query_name}")
|
||||
obj = QUERY_OBJECTS[query_name]
|
||||
@@ -227,7 +227,7 @@ def get_query_object(
|
||||
return query_object
|
||||
|
||||
|
||||
def _get_postprocessing_operation(query_name: str) -> List[Dict[str, Any]]:
|
||||
def _get_postprocessing_operation(query_name: str) -> list[dict[str, Any]]:
|
||||
if query_name not in QUERY_OBJECTS:
|
||||
raise Exception(
|
||||
f"Post-processing fixture not defined for datasource: {query_name}"
|
||||
@@ -250,8 +250,8 @@ class QueryContextGenerator:
|
||||
add_time_offsets: bool = False,
|
||||
table_id=1,
|
||||
table_type="table",
|
||||
form_data: Optional[Dict[str, Any]] = None,
|
||||
) -> Dict[str, Any]:
|
||||
form_data: Optional[dict[str, Any]] = None,
|
||||
) -> dict[str, Any]:
|
||||
form_data = form_data or {}
|
||||
table_name = query_name.split(":")[0]
|
||||
table = self.get_table(table_name, table_id, table_type)
|
||||
|
||||
Reference in New Issue
Block a user