mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-46120: State that |
is preferred over Union
(GH-30222)
Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
This commit is contained in:
parent
b8de8b7039
commit
1b30660c3b
2 changed files with 2 additions and 1 deletions
|
@ -625,7 +625,7 @@ These can be used as types in annotations using ``[]``, each having a unique syn
|
|||
|
||||
Union type; ``Union[X, Y]`` is equivalent to ``X | Y`` and means either X or Y.
|
||||
|
||||
To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | str``. Details:
|
||||
To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | str``. Using that shorthand is recommended. Details:
|
||||
|
||||
* The arguments must be types and there must be at least one.
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
State that ``|`` is preferred for readability over ``Union`` in the :mod:`typing` docs.
|
Loading…
Add table
Add a link
Reference in a new issue