-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
@property on subclass raises error #8912
Comments
This is because Example:
|
Ah, thank you. Could there be a clearer error message for this? Also, should this work then: class Superclass:
prop: int
class Subclass(Superclass):
@property
def prop(self) -> int:
...
@prop.setter
def prop(self, val: int) -> None:
... Because I get the same errors there, but that addresses this concern. |
Hm, yes. That should be allowed unless I'm missing something. Technically it's unsafe because the base class would allow |
I think this is a duplicate of #4125 |
Yeah, looks like a duplicate of #4125. |
Thanks for figuring this out! |
Defining a property in a superclass and then using a
@property
decorator in a subclass does not detect that the signatures match.I think this is a bug, but I'm not sure if there are some edge cases I haven't thought through that make this error valid.
Here's code:
The mypy error:
Mypy
--version
ismypy 0.770
.I tried to look through the list of issues with
@property
but couldn't determine if this is a duplicate; the others (that seem largely resolved) have to do with@property
whereas this has to do with@property
when in a subclass with a superclass that has a type annotation.This might be a duplicate of #5936; if so, please close this. I wasn't sure because that seems to have to do with setters, which this does not.
The text was updated successfully, but these errors were encountered: