-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Generate an error if trying to use @final with TypedDict #7865
Generate an error if trying to use @final with TypedDict #7865
Conversation
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.
Thanks! Looks good, could you please add a test case for this (see test-data/unit/check-typeddict.test
)
Co-Authored-By: Ivan Levkivskyi <[email protected]>
@ilevkivskyi I add a test case called |
test-data/unit/check-typeddict.test
Outdated
str_val: str | ||
|
||
[builtins fixtures/dict.pyi] | ||
[typing fixtures/typing-full.pyi] |
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.
Please add a newline at the end of file.
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.
👍
Fixes #7849
This fix modifies function
analyze_class
inmypy/semanal.py
, if the analyzer identifies aTypedDict
, it then traverses all decorators and checks if@final
exists, and if so, generate an error.The code is very straightforward, but I think it has room for potential improvement in terms of clarity.