[ty] Allow stringified argument in PEP 613 alias to Optional#23200
Merged
[ty] Allow stringified argument in PEP 613 alias to Optional#23200
Optional#23200Conversation
Typing conformance resultsNo changes detected ✅ |
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
|
AlexWaygood
approved these changes
Feb 10, 2026
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-type-form |
4 | 4 | 0 |
unused-type-ignore-comment |
0 | 1 | 0 |
| Total | 4 | 5 | 0 |
Member
|
The new hits on strawberry/discord/ibis all look similar to astral-sh/ty#727 (and I don't think it's really required for type checkers to support things like that — I think those new diagnostics are fine personally. These are edge cases that generally only come up in test suites or in libraries that do metaprogramming) |
Contributor
Author
Yes, thank you. I agree. |
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
The argument of
Optional[…]in value position was previously inferred as a value expression, but there is no need for that. We know that the argument is always a type expression. This change allows us to handle stringified arguments correctly. We already do the same for similar special forms liketyping.Union.closes astral-sh/ty#2770
Test Plan
Added regression test and some related additional tests.