@@ -5364,7 +5364,7 @@ Union Type
53645364A union object holds the value of the ``| `` (bitwise or) operation on
53655365multiple :ref: `type objects <bltin-type-objects >`. These types are intended
53665366primarily for :term: `type annotations <annotation> `. The union type expression
5367- enables cleaner type hinting syntax compared to :data : `typing.Union `.
5367+ enables cleaner type hinting syntax compared to subscripting :class : `typing.Union `.
53685368
53695369.. describe :: X | Y | ...
53705370
@@ -5400,9 +5400,10 @@ enables cleaner type hinting syntax compared to :data:`typing.Union`.
54005400
54015401 int | str == str | int
54025402
5403- * It is compatible with :data : `typing.Union `::
5403+ * It creates instances of :class : `typing.Union `::
54045404
54055405 int | str == typing.Union[int, str]
5406+ type(int | str) is typing.Union
54065407
54075408 * Optional types can be spelled as a union with ``None ``::
54085409
@@ -5428,16 +5429,15 @@ enables cleaner type hinting syntax compared to :data:`typing.Union`.
54285429 TypeError: isinstance() argument 2 cannot be a parameterized generic
54295430
54305431The user-exposed type for the union object can be accessed from
5431- :data: `types.UnionType ` and used for :func: `isinstance ` checks. An object cannot be
5432- instantiated from the type::
5432+ :class: `typing.Union ` and used for :func: `isinstance ` checks::
54335433
5434- >>> import types
5435- >>> isinstance(int | str, types.UnionType )
5434+ >>> import typing
5435+ >>> isinstance(int | str, typing.Union )
54365436 True
5437- >>> types.UnionType ()
5437+ >>> typing.Union ()
54385438 Traceback (most recent call last):
54395439 File "<stdin>", line 1, in <module>
5440- TypeError: cannot create 'types.UnionType ' instances
5440+ TypeError: cannot create 'typing.Union ' instances
54415441
54425442.. note ::
54435443 The :meth: `!__or__ ` method for type objects was added to support the syntax
@@ -5464,6 +5464,11 @@ instantiated from the type::
54645464
54655465.. versionadded :: 3.10
54665466
5467+ .. versionchanged :: 3.14
5468+
5469+ Union objects are now instances of :class: `typing.Union `. Previously, they were instances
5470+ of :class: `types.UnionType `, which remains an alias for :class: `typing.Union `.
5471+
54675472
54685473.. _typesother :
54695474
0 commit comments