On Sun, 25 Jul 2021, 9:26 pm Serhiy Storchaka, <storchaka@gmail.com> wrote:
In 3.10 the union type (the type of the result of the | operator for
types) was added (https://www.python.org/dev/peps/pep-0604/). It is
exposed as types.Union. There are differences between typing.Union and
types.Union:

* typing.Union is indexable, types.Union is not.
* types.Union is a class, typing.Union is not.

types.Union corresponds to private class typing._UnionGenericAlias, not
typing.Union. It is confusing that typing.Union and types.Union have the
same name but are so different. Note also that most classes in the types
module have the "Type" suffix: FunctionType, MethodType, ModuleType,
etc. I think that it would be better to rename types.Union to
types.UnionType.

If we wanted to be completely explicit, the most exact name would be "TypeUnionType": it is the type of object you get specifically when unioning types, not when unioning arbitrary objects.

Cheers,
Nick.