Repository navigation
Conversation
Skip over attributes that are redefined as properties on dataclass construction
ilevkivskyi
left a comment
There was a problem hiding this comment.
Thanks for the PR! I have one suggestion.
The failure in CI seems to be caused by #6432, so that should be fixed first.
| assert isinstance(node, (Var, OverloadedFuncDef)) | ||
|
|
||
| if isinstance(node, OverloadedFuncDef): | ||
| continue |
There was a problem hiding this comment.
This is still dangerous, what if node is a Decorator? I would just replace the old assert with if not isinstance(node, Var): continue.
|
@ilevkivskyi Thanks for the suggestion. I think you are right but I can't seem to wrap my head around the possible edge cases. |
|
Thanks for update! Unfortunately, we will need to wait with this PR until #6432 is fixed. |
|
This PR may be unblocked now. Could you please rebase on current master? Also it looks like a fix identical to the one you add may also fix #6715 would you like to add it to this PR? Thank you! |
|
@ilevkivskyi Sorry for the delay, I was absent for a while due to personal obligations. Is this still okay to merge? |
|
@ckanesan No problem. Please note there is still a (legitimate) failure on the new semantic analyzer. So you should probably update the test to only run on new analyzer, or put a type ignore on that line. |
|
Also as I mentioned there is almost identical issue for attrs #6715. It would be great if you can fix it too. |
|
Jukka closed the original issue, #6493 (comment)
I am going to close this PR since it's inactive. Feel free to open a new one at your convenience! |
Skip over attributes that are redefined as properties on dataclass construction.
As far as I understand, not redefining a symbol within the same scope is a fundamental assumption in mypy. However, I have not been able to figure out another way to get a mutable property that is also part of the
dataclasses.fields. It seems that we are falling within the cracks in the sense that the property methods actually mask the attribute with the desired functionality and all seems to go well in the end.Any indications on how to make a cleaner implementation would be most welcome!
Fixes #6493