From: Nikita Sobolev Date: Fri, 24 Dec 2021 21:36:09 +0000 (+0300) Subject: bpo-46120: State that `|` is preferred over `Union` (GH-30222) X-Git-Tag: v3.11.0a4~144 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b30660c3b40da557050948ac8635f2dc50c4ee2;p=thirdparty%2FPython%2Fcpython.git bpo-46120: State that `|` is preferred over `Union` (GH-30222) Co-authored-by: Éric Co-authored-by: Guido van Rossum --- diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 727941b57b54..08b59d84246f 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -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. diff --git a/Misc/NEWS.d/next/Documentation/2021-12-21-12-45-57.bpo-46120.PE0DmJ.rst b/Misc/NEWS.d/next/Documentation/2021-12-21-12-45-57.bpo-46120.PE0DmJ.rst new file mode 100644 index 000000000000..17f67472e2ab --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2021-12-21-12-45-57.bpo-46120.PE0DmJ.rst @@ -0,0 +1 @@ +State that ``|`` is preferred for readability over ``Union`` in the :mod:`typing` docs.