You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use X | Y union syntax in error messages on recent Python versions #15082
As a follow-up to #15070, display union types using the new X | Y syntax in error messages when targeting Python 3.10 or later.
Examples:
Instead of Union[int, str], display int | str.
Instead of Optional[str], display str | None
If there is None in a union type, perhaps always display the None as the final item. This way we'd never show a type like None | str (even if type inference would produce this internal representation), since it's not idiomatic.
Generalize the implementation technique used in #15070, which added a version check for using list[x] instead of List[x] in error messages on Python 3.9 and later. In particular, use the hidden command line option in tests to always use the old syntax, so that tests will run consistently. Add specific test cases that enable the X | Y syntax only in the new tests that test this syntax.
Activity
Use X | Y union syntax in error messages (#15102)