Skip to content

Merge 'types.UnionType' with typing._UnionGenericAlias, not typing.Union #137065

@serhiy-storchaka

Description

@serhiy-storchaka

Bug report

I think #105499 was a mistake. types.UnionType was intentionally named so to avoid confusion with typing.Union (see #88895). types.UnionType should not be subscriptable because it is not generic type (and if it was a generic type, subscription would have different semantic than for typing.Union). types.UnionType corresponds to typing._UnionGenericAlias, not typing.Union (see #89581 (comment)).

So we should restore typing.Union, make typing._UnionGenericAlias an alias of types.UnionType, and make types.UnionType non-subscriptable again.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixesrelease-blockertopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions