[ty] Parenthesize callable types when they appear in the return annotation of other callable types#23327
Merged
AlexWaygood merged 5 commits intomainfrom Feb 16, 2026
Merged
Conversation
Callable types displayed with arrow syntax (e.g., `(int) -> str`) are now parenthesized when they appear as parameter annotations or return types of other callables, to avoid ambiguity in nested callable displays. For example, `(int) -> (str) -> bool` is now displayed as `(int) -> ((str) -> bool)`, making it clear that the return type is itself a callable. Overloaded callables (displayed as `Overload[...]`) and callables with top-materialization parameters (displayed as `Top[...]`) are excluded from parenthesization since their bracket syntax is already unambiguous. https://claude.ai/code/session_01VMrqDstEBv8ntfum4Mg2Sj
Narrow the parenthesization to return-type annotations only, not parameter annotations, for better readability. Callable types displayed with arrow syntax (e.g., `(int) -> str`) are now parenthesized when they appear as the return type of another callable, to avoid ambiguity like `(int) -> (str) -> bool` which is now displayed as `(int) -> ((str) -> bool)`. Overloaded callables (displayed as `Overload[...]`) and callables with top-materialization parameters (displayed as `Top[...]`) are excluded since their bracket syntax is already unambiguous. https://claude.ai/code/session_01VMrqDstEBv8ntfum4Mg2Sj
Typing conformance resultsNo changes detected ✅ |
|
Memory usage reportMemory usage unchanged ✅ |
AlexWaygood
commented
Feb 16, 2026
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
A revealed type like this is pretty hard to read, because it's unclear which
->operator has higher precedence over the other:this PR changes our type display for callables returning callables, so that the type is instead printed like this, which is... a bit easier to parse, at least:
Test Plan
mdtests updated