Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a class attribute hook to the plugin system #9881
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
Add a class attribute hook to the plugin system #9881
Changes from all commits
23aeeb0
f1852e1
bbac561
379aa60
987207a
a976739
af49c12
1816cf6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 suggest to use one more test example with real
B
, because subtypingAny
is not the same as subtyping a regular class.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.
Added!
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.
What about
self.__class__.attr
? Should we support that?I think we can also check that
c: Type[Cls]; c.attr
works correctly.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.
Hm, so it looks like adding a test for
__class__
is actually somewhat difficult, but also unclear that it actually adds much new value here. In particular it looks like the__class__
being specified as generic is done in typeshed here: https://github.com/python/typeshed/blob/master/stdlib/builtins.pyi#L87-L88The way this is done in other tests is via
[builtins fixtures/__new__.pyi]
but that just defines__class__ = object
and isn't generic. But even if we were able to use the real stubs, then really all that__class__
would be testing is that the generics system+stubs work correctly, and less about the class attribute plugin itself. But if you think testing the generic__class__
is important I can add the stub manually within this test!The other one is already tested above:
mypy/test-data/unit/check-custom-plugin.test
Lines 918 to 919 in af49c12