Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Allow to use Final and ClassVar after python 3.13#18358
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hauntsaninja left a comment
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.
Thank you!
mypy/typeanal.py Outdated
| code=codes.VALID_TYPE, | ||
| ) | ||
| else: | ||
| elifself.options.python_version< (3,13): |
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.
We should still error in several of the cases this previously triggered, e.g.def f(x: Final[int]) -> int: ... (grep the test cases forFinal can be only used as an outermost qualifier for examples)
This comment has been minimized.
This comment has been minimized.
mypy/semanal.py Outdated
| node.is_classvar=True | ||
| analyzed=self.anal_type(s.type) | ||
| analyzed=self.anal_type( | ||
| s.type,allow_final_in_classvar=self.options.python_version>= (3,13) |
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 think this one might be unnecessary? Let me push to your PR
for more information, seehttps://pre-commit.ci
hauntsaninja left a comment
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.
Thank you for this improvement!
aliwo commentedDec 30, 2024
@hauntsaninja Thank you very much! |
According tomypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
80e5e8b intopython:masterUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Hi, Thanks for making a great library! I've been using mypy for years and it saved me from several (possibly happened) accidents!
Description
this PR allows to use Final and ClassVar after python 3.13
I saw thisPR
and I saw recent changes of python 3.13

https://docs.python.org/3/library/typing.html#typing.Final
Final now can be nested with ClassVar. so I added a version check!