mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +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
|
||||
|
||||
Reference in New Issue
Block a user