Skip to content

Commit 1b30660

Browse files
sobolevnmerwokgvanrossum
authored
bpo-46120: State that | is preferred over Union (GH-30222)
Co-authored-by: Éric <[email protected]> Co-authored-by: Guido van Rossum <[email protected]>
1 parent b8de8b7 commit 1b30660

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)