Revert "Add support for attrs.fields (#15021)"#15393
Revert "Add support for attrs.fields (#15021)"#15393jhance wants to merge 1 commit intopython:masterfrom
attrs.fields (#15021)"#15393Conversation
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.
JukkaL
left a comment
There was a problem hiding this comment.
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.Attributewould likely be more useful to callsites ofattr.fields- otherwise this currently results in inferringbuiltins.objectin 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.