Skip to content

Commit ed1671c

Browse files
[3.10] bpo-46120: State that | is preferred over Union (GH-30222) (GH-30250)
Co-authored-by: Éric <[email protected]> Co-authored-by: Guido van Rossum <[email protected]> (cherry picked from commit 1b30660) Co-authored-by: Nikita Sobolev <[email protected]> Automerge-Triggered-By: GH:gpshead
1 parent 576e38f commit ed1671c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Doc/library/typing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ These can be used as types in annotations using ``[]``, each having a unique syn
625625

626626
Union type; ``Union[X, Y]`` is equivalent to ``X | Y`` and means either X or Y.
627627

628-
To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | str``. Details:
628+
To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | str``. Using that shorthand is recommended. Details:
629629

630630
* The arguments must be types and there must be at least one.
631631

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
State that ``|`` is preferred for readability over ``Union`` in the :mod:`typing` docs.

0 commit comments

Comments
 (0)