-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Regression: descriptors don't work on protocols #19262
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
Thanks! Closing as duplicate of #19054 |
As a workaround, you can try annotating the protocol member as a |
Good idea, but unfortunately this makes actual classes incompatible with the protocol: https://mypy-play.net/?mypy=1.16.0&python=3.11&gist=9321d98d479917bd489d5be8872a509b |
Mypy will accept it if you also annotate the class assignments as |
Yeah, I don't want to update all my classes to work-around something that will hopefully get fixed. |
It's also pretty verbose and ugly. Your snippet is missing the type argument to |
Descriptors don't work when used as attributes on Protocols. The same code works on a regular class. This worked for many years up to and including mypy 1.15, but stopped working in 1.16.
To Reproduce
https://mypy-play.net/?mypy=1.16.0&python=3.11&gist=e1f1bd3254690db213102de71f894854
Expected Behavior
This code should type-check. If works with mypy 1.15 or when
HasDesc
is not a protocol.Actual Behavior
Your Environment
The text was updated successfully, but these errors were encountered: