-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Implement ClassVar semantics (fixes #2771) #2873
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d6b370d
Implement ClassVar semantics (fixes #2771)
miedzinski 950b383
Fix type annotations
miedzinski cdfdbbc
Remove ClassVarType, use Var.is_classvar flag
miedzinski 01a7a69
Add test case against TypeVar
miedzinski d52b4e3
Fix if statement in check_classvar_definition
miedzinski 15e1e85
Change error message about ClassVar arg count
miedzinski 781245f
Add more tests
miedzinski cd61a5d
Remove duplicate test case
miedzinski 9c29911
Move ClassVar override checks to TypeChecker
miedzinski b618718
Prohibit ClassVar inside other types or in signatures
miedzinski cb6786f
Prohibit defining ClassVars on self
miedzinski a427d61
Add more tests
miedzinski 35e2c68
Fix analysing implicit tuple types
miedzinski e121158
Add more meaningful error message on attribute override
miedzinski 5e2aafc
Add better error message on assignments
miedzinski 137215e
Add more precise errors on ClassVar definitions
miedzinski 5dd131a
Minor style improvements
miedzinski 30a4185
Prohibit ClassVars in for and with statements
miedzinski bcce34d
Rename check_classvar_definition to is_classvar
miedzinski 7ddca4b
Don't consider types in signatures as nested
miedzinski 92b3532
Prohibit generic class variables
miedzinski 20b1abe
Prohibit access to generic instance variables via class
miedzinski 3362e65
Merge branch 'master' into classvar
miedzinski 5430b32
Add incremental checking test
miedzinski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Is this change really necessary? I am asking for two reasons:
TupleType
with corresponding number ofAny
s as items, instead of just plainAnyType()
intypeanal.py
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.
My bad. I've restored old behaviour, although in
TypeAnalyser
. This is needed if we want to fail onSince I've removed the test for this we could allow this, but these variables wouldn't get
is_classvar
flag. I would keep it as is.