You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can get that back by instead doing the context manager approach as the first thing that happens in the function, but that defeats the point of having the decorator:
Adds a `DecoratedCallable` TypeVar and uses that in the type hints for the
`__call__` method in `LoggingContext`. This allows type information to pass
through correctly when used as a decorator.
It seems like the `@wraps` decorator on the wrapper mangles the type info so I
had to disable type checking on the return because Pyright was convinced it was
wasn't the correct type, but the tests proved otherwise.
I'm not sure there's a good way to test since at runtime the function signature
is getting passed through correctly. It's only on the type checking pass that
things break down. It's probably fine as-is since no tests broke as a result,
but figured it was worth mentioning.
Fixestackle-io#60
Adds a `DecoratedCallable` TypeVar and uses that in the type hints for the
`__call__` method in `LoggingContext`. This allows type information to pass
through correctly when used as a decorator.
It seems like the `@wraps` decorator on the wrapper mangles the type info so I
had to disable type checking on the return because Pyright was convinced it was
wasn't the correct type, but the tests proved otherwise.
I'm not sure there's a good way to test since at runtime the function signature
is getting passed through correctly. It's only on the type checking pass that
things break down. It's probably fine as-is since no tests broke as a result,
but figured it was worth mentioning.
Fixestackle-io#60
If you want to use the
LoggingContext
in the decorator style, you lose the typechecking of the decorated function.I can get that back by instead doing the context manager approach as the first thing that happens in the function, but that defeats the point of having the decorator:
Mypy has a page on how to set this up: https://mypy.readthedocs.io/en/stable/generics.html#declaring-decorators
The text was updated successfully, but these errors were encountered: