-
-
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
Treat Any
metaclass the same as Any
base class
#13605
Conversation
Also |
test-data/unit/check-classes.test
Outdated
|
||
reveal_type(WithMeta.a) # N: Revealed type is "Any" | ||
reveal_type(WithMeta.m) # N: Revealed type is "Any" | ||
reveal_type(WithMeta.x) # N: Revealed type is "builtins.int" |
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.
Maybe add a couple of tests to check/clarify that this only affects class objects, not instances of classes?
reveal_type(WithMeta.x) # N: Revealed type is "builtins.int" | |
reveal_type(WithMeta.x) # N: Revealed type is "builtins.int" | |
reveal_type(WithMeta().a) # E: "WithMeta" has no attribute "a" \ | |
# N: Revealed type is "Any" | |
reveal_type(WithMeta().x) # N: Revealed type is "builtins.int" |
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.
Sure!
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Can't you just do this?
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
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.
I don't feel qualified to comment on whether this is the best way to implement this, but the tests look great!
@AlexWaygood you can see that I was copying the approach we have for base classes: Lines 1894 to 1900 in 9d21615
Basically, it uses this mechanism: Lines 2738 to 2743 in 9d21615
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
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.
Looks great!
Closes #13599