diff --git a/woodchipper/context.py b/woodchipper/context.py index 4e372c9..5a89bc3 100644 --- a/woodchipper/context.py +++ b/woodchipper/context.py @@ -5,12 +5,13 @@ from collections.abc import MutableMapping from decimal import Decimal from functools import wraps -from typing import Any, Mapping, NamedTuple, Optional, Tuple, Union, cast +from typing import Any, Callable, Mapping, NamedTuple, Optional, Tuple, TypeVar, Union, cast import woodchipper LoggableValue = Optional[Union[str, int, bool, Decimal, float]] LoggingContextType = Mapping[str, LoggableValue] +DecoratedCallable = TypeVar("DecoratedCallable", bound=Callable[..., Any]) class Missing: @@ -197,7 +198,7 @@ def __exit__(self, exc_type, exc_val, exc_tb): self._token = None return False - def __call__(self, f): + def __call__(self, f: DecoratedCallable) -> DecoratedCallable: self.decorator_mapping = _build_path_head_to_param_config_map( self.injected_context, delimiter=self.path_delimiter ) @@ -239,7 +240,7 @@ def wrapper(*func_args, **func_kwargs): with self: return f(*func_args, **func_kwargs) - return wrapper + return wrapper # type: ignore logging_ctx = LoggingContextVar("logging_ctx")