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
It would be nice if we don't, because that will allow us to get accurate signatures for more decorated functions. When I tried this, it caused problems with some decorators that modify the function's signature but use @functools.wrap, notably @mock.patch (which passes additional arguments to the decorated function). I've also run into issues with @contextlib.contextmanager, which changes the return type of the decorated function.
Possible solutions:
Modify these decorators to set an accurate .__signature__ attribute on the decorated function (but that's not an option for third-party decorators)
Add special casing for some of these. For example, patched functions have a .patchings attribute; we could internally ignore the parameter corresponding to any entries in .patchings that have their .new attribute set to mock.DEFAULT. But there doesn't seem to be a similar way to identify a function that was decorated with @contextmanager.
The text was updated successfully, but these errors were encountered:
#471 found a concrete place where this costs us type checking capabilities in pyanalyze's self check: methods annotated with qcore.caching.cached_per_instance().
In signature.py, we use
follow_wrapped=False
when getting the signature of a callable:pyanalyze/pyanalyze/arg_spec.py
Line 449 in 2ae6915
It would be nice if we don't, because that will allow us to get accurate signatures for more decorated functions. When I tried this, it caused problems with some decorators that modify the function's signature but use
@functools.wrap
, notably@mock.patch
(which passes additional arguments to the decorated function). I've also run into issues with@contextlib.contextmanager
, which changes the return type of the decorated function.Possible solutions:
.__signature__
attribute on the decorated function (but that's not an option for third-party decorators).patchings
attribute; we could internally ignore the parameter corresponding to any entries in.patchings
that have their.new
attribute set tomock.DEFAULT
. But there doesn't seem to be a similar way to identify a function that was decorated with@contextmanager
.The text was updated successfully, but these errors were encountered: