-
-
Notifications
You must be signed in to change notification settings - Fork 3k
class with __setattr__ reports properties are read-only #9160
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
Yeah, this looks like false positive. |
Anybody want to contribute a fix -- it should be easy? Add a check about |
@JukkaL I can take care of this. |
I reverted the fix #9196 in #9474. Copying my comment from the revert:
I realised that object in typeshed has E.g, this would no longer produce an error:
Additionally, it introduces a broken test on master, since we (unintentionally) don't run some Python2 tests in CI (filed as #9473 )
I'm not sure what the path forward is. Maybe it's okay to merge a version that doesn't check the MRO (as in the original PR), or maybe we exclude object's |
Thanks for the details @hauntsaninja. Even if Here is my workaround; it allows for:
mypy will identify the last line as an error, but not the penultimate line.
|
I haven't seen much request for this feature in the intervening years, and I think fixing the false positive here would hurt many more common cases. |
Uh oh!
There was an error while loading. Please reload this page.
When a class implements
__setattr__
, mypy still reports properties as read-only.Minimum example:
The error points to the last line in the above code:
error: Property "a" defined in "Foo" is read-only
.Expectation: Since
Foo
implements__setattr__
, mypy should allow the attribute to be set, even though it overlaps with a class property.There are no issues identified if the property
a
is removed, and I am using version 0.781.The text was updated successfully, but these errors were encountered: