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
The function signature is handled correctly (as per #4399), but the fact ContextDecorator.__call__ necessarily adds the __wrapped__ attribute to the returned wrapper is lost.
The functools stub does have some machinery for accurately typing functools.wraps itself, but there isn't anything that could be readily used to adjust the ContextDecorator.__call__ signature.
Ideally something like the following would be possible:
However, I'm not sure how _WrappedCallable could be expressed as a generic type - the corresponding protocol in functools.pyi accepts the call parameters and return type as separate type variables.
The text was updated successfully, but these errors were encountered:
I recently ran into the problem described in https://stackoverflow.com/questions/62703400/python-how-to-type-hint-a-callable-with-wrapped, where MyPy complained when I attempted to access
__wrapped__
on a function decorated with aContextDecorator
subclass.The function signature is handled correctly (as per #4399), but the fact
ContextDecorator.__call__
necessarily adds the__wrapped__
attribute to the returned wrapper is lost.The
functools
stub does have some machinery for accurately typingfunctools.wraps
itself, but there isn't anything that could be readily used to adjust theContextDecorator.__call__
signature.Ideally something like the following would be possible:
However, I'm not sure how
_WrappedCallable
could be expressed as a generic type - the corresponding protocol infunctools.pyi
accepts the call parameters and return type as separate type variables.The text was updated successfully, but these errors were encountered: