Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
Currently, unions created throughtyping.Union[A, B] and through thePEP-604 syntaxA | B are at runtime instances of completely different types, and they differ in exactly what elements they accept. This is confusing and makes it harder for users to detect unions at runtime.
I propose to proceed in two steps:
- Make
typing.Unionan alias fortypes.UnionTypeand make it sotypes.UnionType[A, B]works, accepting the same typesUnionaccepts now. - Loosen the rules for what the
|operator accepts to accept more types that are commonly used in unions.