-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Mishandles self
argument of wrapped method
#4843
Comments
The change is due to a recent change in the typeshed stub file I don't see an obvious way to make this case work through modification of the typeshed declaration without breaking other (more common) use cases of I'm curious what you're trying to do with this code. I don't think I've seen |
Here's a potential workaround: class B:
def meth(self, x: int) -> int:
return x + 1
# Copy docstring from A.meth
functools.update_wrapper(meth, A.meth, assigned=["__doc__"]) |
Thanks very much for explaining and the suggested workaround. I had assumed the latest typeshed would be installed whenever pyright was installed so thought pyright was the cause, rather than the bundled typeshed definitions. That makes sense that you don't want to special case this in pyright.
Yes, what I'm actually trying to do is copy over doc strings, type annotations and default argument values from In my actual project I have a parent |
Describe the bug
Pyright does not recognise that an instance of a class is implicitly passed to the
self
argument of a class method decorated with@functools.wraps
.To Reproduce
With pyright
1.1.300
and Python 3.9.13Results in two errors
It seems to expect
B.meth(b, x)
rather thanb.meth(x)
Expected behavior
I believe pyright should report no errors in the above. Pyright
1.1.285
does not report any errors but1.1.298
and onwards does so I suspect this is an issue with pyright, rather than typeshed.VS Code extension or command-line
I find an the error reported in this case with both the command line pyright 1.1.300 and Pylance
The text was updated successfully, but these errors were encountered: