-
-
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
decouple types.DynamicClassAttribute from property #13276
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
def __set__(self, instance: Any, value: Any) -> None: ... | ||
def __delete__(self, instance: Any) -> None: ... | ||
def getter(self, fget: Callable[[Any], Any]) -> DynamicClassAttribute: ... | ||
def setter(self, fset: Callable[[Any, Any], None]) -> DynamicClassAttribute: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want the special semantics where you can write @foo.setter
later without type checkers complaining about a duplicate definition. That may be hard to achieve without aliasing property
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll put together a test to find out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that it works as expected in mypy but not pyright.
This comment has been minimized.
This comment has been minimized.
I opened a pyright issue for the test failure here. |
Pyright doesn't plan to support this, so there's nothing else to do here. |
After looking into it a little more, it seems like we can avoid regressions in pyright by pretending that DynamicClassAttribute inherits from property. That seems less wrong than pretending that it's just an alias for property. |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
In addition to the cleared allowlist entries, this improves the inheritance of
enum.property
.Previous: #12762
This is now enabled by mypy 1.14 and python/mypy#18150.