clarify Final reassignment semantics#2241
Conversation
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.
| @@ -1,45 +1,47 @@ | |||
| conformant = "Pass" | |||
| conformant = "Partial" | |||
There was a problem hiding this comment.
There should be notes added here explaining in English what the gap to conformance is.
| conformance_automated = "Pass" | ||
| conformance_automated = "Partial" | ||
| errors_diff = """ | ||
| Line 30: Unexpected errors ['qualifiers_final_annotation.py:30:17: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `bool`'] |
There was a problem hiding this comment.
As commented below, this is a bug in the added conformance test, not a conformance gap in ty.
| @@ -1,33 +1,41 @@ | |||
| conformance_automated = "Pass" | |||
| conformance_automated = "Partial" | |||
There was a problem hiding this comment.
There should also be notes added here explaining the conformance gap.
docs/spec/qualifiers.rst
Outdated
| * There must be *exactly one* assignment to a final name. | ||
| * A final name must never be *reassigned*. There may be multiple | ||
| assignments to a final name, as long as at most one assignment can | ||
| be reached at runtime (e.g. in an ``if``/``else``` branch). For example:: |
There was a problem hiding this comment.
It doesn't make sense to cover the edge case (multiple branches) first and the basic case (linear code, the existing example) second. The examples should be re-ordered.
da36cdc to
db50e16
Compare
https://discuss.python.org/t/clarify-final-assignment/106878