Skip to content

[ty] Validate sentinel names against assignment targets - #27206

Draft
carljm wants to merge 1 commit into
mainfrom
cjm/ty-4091-sentinel-name-mismatch
Draft

[ty] Validate sentinel names against assignment targets#27206
carljm wants to merge 1 commit into
mainfrom
cjm/ty-4091-sentinel-name-mismatch

Conversation

@carljm

@carljm carljm commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes astral-sh/ty#4091.

Report mismatched-type-name when the name passed to Python 3.15 builtins.sentinel or typing_extensions.Sentinel does not match its assignment target. Accept unqualified and exactly class-qualified sentinel names, including nested classes, without accepting incorrect or partially qualified class paths. Preserve normal call inference for malformed constructor arguments, and update the lint documentation, generated rule reference, and ty schema.

Test plan

Add mdtests for mismatched builtin and typing_extensions sentinels across supported Python versions. Cover aliased constructors, positional and keyword repr, valid and invalid class-qualified names, and nested class paths.

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Jul 27, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 96.84%. The percentage of expected errors that received a diagnostic held steady at 92.11%. The number of fully passing files held steady at 99/133.

@astral-sh-bot

astral-sh-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@carljm
carljm marked this pull request as ready for review July 27, 2026 06:10
@carljm
carljm requested review from a team as code owners July 27, 2026 06:10
@astral-sh-bot
astral-sh-bot Bot requested a review from dcreager July 27, 2026 06:10
@astral-sh-bot

astral-sh-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@carljm

carljm commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Marking this as draft because python/typing#2277 actually proposes to require that type checkers not error on this mismatch. Until that's resolved we shouldn't add this check.

@carljm
carljm marked this pull request as draft July 27, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

no error when sentinel name does not match variable name

1 participant