-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Descriptors shouldn't be considered callable inside class definition #2267
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
Comments
Ugh. Mypy's lack of understanding of class vs. instance attributes strikes again. :-( |
I would expect mypy to mimic the runtime - treat the current block as if it was not inside a class definition, then send the definitions to a "metaclass" (hard coded, in the case to Does that make sense at all? As far as I understand, this isn't how it's done, currently - not even remotely similar. |
Would be good to fix but probably complicated. |
I think you meant "decorators" in the title, not "descriptors", right? (A decorator uses |
@gvanrossum Well, I meant descriptors because of the |
Ah, got it. |
This doesn't appear to generate a runtime exception with newer versions of Python, so it's no longer a false negative in mypy. |
The runtime change is from https://bugs.python.org/issue43682 which was included in Python 3.10. |
Closing as won't fix, though if anyone feels inspired to write a PR for 3.9 feel free to |
The following is an error in Python but passes mypy's checks:
Error:
Same thing goes for
classmethod
.The text was updated successfully, but these errors were encountered: