Skip to content

clarify Final reassignment semantics#2241

Open
KotlinIsland wants to merge 1 commit intopython:mainfrom
KotlinIsland:final-reassignment
Open

clarify Final reassignment semantics#2241
KotlinIsland wants to merge 1 commit intopython:mainfrom
KotlinIsland:final-reassignment

Conversation

@KotlinIsland
Copy link
Copy Markdown
Contributor

@KotlinIsland KotlinIsland commented Apr 7, 2026

Copy link
Copy Markdown
Member

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`']
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should also be notes added here explaining the conformance gap.

* 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::
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants