Repository navigation
Conversation
|
✅ This PR meets all requirements from our pull request checklist. Note: this comment updates automatically after changes to the PR. Updates may take up to half an hour. |
…sions
A sentinel assigned with an annotation went through the ordinary assignment
path and became a value, so `MARKER: Final = sentinel("MARKER")` could not
be used as a type. Bind such sentinels like unannotated ones when the
annotation is a bare Final or ClassVar.
1-DARK
force-pushed
the
fix-sentinel-qualifier
branch
from
November 7, 2026 16:28
79b59cc to
c3cd030
Compare
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D130435706. (Because this pull request was imported automatically, there will not be any future comments.) |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This branch has not been deployed
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.
Summary
MARKER: Final = sentinel("MARKER")andMARKER: ClassVar = sentinel("MARKER")boundMARKERas a plain value, soint | MARKERreportednot-a-type. The unannotated form already worked.Annotated assignments never reached
assign_sentinel. They went through the ordinary assignment path. A bareFinalorClassVarcarries no type, so such sentinels are now bound like unannotated ones. Annotations that carry a type (A: A = Sentinel("A"),A: Any = ...) keep their current behavior, which existing tests rely on.ClassVaris not a special export, so it is matched by name (ClassVarorx.ClassVar). An aliased import such asClassVar as CVis not detected.Fixes #5560
Test Plan
Added
test_sentinel_with_type_qualifierinpyrefly/lib/test/sentinel.rs, covering theClassVarandFinalcases from the issue.cargo test sentinelpasses.