-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Revert "Add support for attrs.fields
(#15021)"
#15393
Conversation
This reverts commit 391ed85. The use of a Union item type for `attr.Attribute` would likely be more useful to callsites of `attr.fields` - otherwise this currently results in inferring `builtins.object` in many cases where we treat the fields as a variable-length tuple, rather than a fixed-length one. Applications of the fixed-length tuple seem limited since you would need to access it by index. @Tinche as the original author of the commit.
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.
One option would be to infer a variable-length tuple with union item type. The issue here is that mypy doesn't use unions for joins.
@JukkaL I'm not in favor of this, see my comment over at #15021 (comment). |
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Limiting the tuple special-casing mentioned in #15396 (comment) to cases where fallback instance is |
I don't think Attribute can be covariant because the validator object is clearly not. I looked into this yesterday. |
Opened an alternate PR to fix this #15688 |
@hauntsaninja thanks <3 |
This reverts commit 391ed85.
The use of a Union item type for
attr.Attribute
would likely be more useful to callsites ofattr.fields
- otherwise this currently results in inferringbuiltins.object
in many cases where we treat the fields as a variable-length tuple, rather than a fixed-length one. Applications of the fixed-length tuple seem limited since you would need to access it by index.@Tinche as the original author of the commit.