ty icon indicating copy to clipboard operation
ty copied to clipboard

Consolidate `type[]` types in a union when displaying them

Open AlexWaygood opened this issue 1 month ago • 3 comments

When displaying a union (e.g. in error messages or on hover), it would be nicer if we displayed the union type[A] | type[B] | type[C] as type[A | B | C]. The latter means the same thing, is a valid type annotation, and is much more concise. This would be similar to the way we display Literal["a"] | Literal[42] | Literal[b"foooo"] as Literal["a", 42, b"foo"] in diagnostics and on hover.

Keeping type display concise where possible makes our diagnostics much more readable.

AlexWaygood avatar Nov 20 '25 11:11 AlexWaygood

Hi @AlexWaygood , I'd like to work on this issue.

mahiro72 avatar Dec 18 '25 14:12 mahiro72

@mahiro72 go for it!

AlexWaygood avatar Dec 18 '25 14:12 AlexWaygood

Please ping us if you need a hand with anything :-)

AlexWaygood avatar Dec 18 '25 14:12 AlexWaygood