PyDocs

Nav

Development Tools

Union

typing

class
Represent a union type

E.g. for int | str
Changed in 3.7, 3.10, 3.14
  • 3.7: Don’t remove explicit subclasses from unions at runtime.
  • 3.10: Unions can now be written as X | Y. See union type expressions.
  • 3.14: types.UnionType is now an alias for Union, and both Union[int, str] and int | str create instances of the same class. To check whether an object is a Union at runtime, use isinstance(obj, Union). For compatibility with earlier versions of Python, use get_origin(obj) is typing.Union or get_origin(obj) is types.UnionType.
0 Examples
No examples for typing/Union.
See Also
No see-alsos for typing/Union
0 Notes
No notes for Union