-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
functools.wraps does not work on class methods #10653
Comments
@erictraut's PR #6670 changed |
@AlexWaygood do you think it's appropriate to stop reverting that change on an ongoing basis now? |
Last I checked it still caused a lot of false positives for mypy users, but it might be worth checking again |
How can I help? |
You could open an experimental draft PR against mypy reverting python/mypy@0dd4b6f and see what mypy_primer says |
With python/mypy#16942 being merged the behavior is now similar between mypy (if installing directly from
|
Oh wait, does that mean that it's fixed for both type checkers, @jakkdl? Or that both mypy and pyright now have the bug, whereas previously it was only pyright? |
Both have the bug now, in that I don't remember enough details from #6347 to figure out if this has the same issue and can't be resolved without |
These tests demonstrate the issue described in python#10653.
These tests demonstrate the issue described in #10653.
Also discussed on discuss.python.org: https://discuss.python.org/t/making-functions-subscriptable-at-runtime/26463/31 |
These tests demonstrate the issue described in python#10653.
The decorators are a bit more complex here than in state.py, so we need a slightly more complicated hint. _Ideally_, we would be able to use `Callable[Concatenate[HasConfig, P], R]` and not have to fish the `HasConfig` out of `args`, but there are some complicated issues with wrapped functions (see python/typeshed#10653 for more context): ``` error: Incompatible return value type (got "_Wrapped[[HasConfig, **P], R, [HasConfig, **P], R]", expected "Callable[[HasConfig, **P], R]") [return-value] ``` --------- Co-authored-by: Sorin Sbarnea <[email protected]>
We recently hit an error using
@wraps
on a class method in Trio: python-trio/trio#2775 (comment) when checked with pyright. It works fine on mypy, but I'm guessing they might be special-casing wraps usage while pyright doesn't.Minimal repro (python 3.11):
mypy 1.5.1 works without any issue, pyright 1.1.325 gives
This smells a lot like the problem with getting functools.cache to work both with methods and functions, see e.g. #6347
The text was updated successfully, but these errors were encountered: