clarify Final reassignment semantics#2241
Open
KotlinIsland wants to merge 1 commit intopython:mainfrom
Open
Conversation
carljm
requested changes
Apr 7, 2026
Member
carljm
left a comment
There was a problem hiding this comment.
I think this is a superior rule, but I would be likely to think so, since it's the rule ty already implements 😆
I think this PR needs some improvements, but I'm in favor of the change.
KotlinIsland
commented
Apr 7, 2026
db50e16 to
790786b
Compare
790786b to
d51cf3d
Compare
carljm
reviewed
Apr 8, 2026
| else: | ||
| ID3 = 2 # OK | ||
|
|
||
| ID4: Final[int] # E: not exhaustive assignment |
Member
There was a problem hiding this comment.
I'm not sure I agree that it should be required to enforce exhaustive assignment. Why should this be enforced for a Final name, but not for other names?
Contributor
Author
There was a problem hiding this comment.
i would expect a type checker to enforce this for all names. but this change is only regarding Final, which to me is even more "static" than normal variables, that a Final name without a value should always be impossible
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://discuss.python.org/t/clarify-final-assignment/106878