Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add type information to LoggingContext.__call__ #79

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions woodchipper/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -208,7 +209,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
)
Expand Down Expand Up @@ -250,7 +251,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")
Loading