]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] bpo-46120: State that `|` is preferred over `Union` (GH-30222) (GH-30250)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 29 Dec 2021 11:45:14 +0000 (03:45 -0800)
committerGitHub <noreply@github.com>
Wed, 29 Dec 2021 11:45:14 +0000 (03:45 -0800)
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
(cherry picked from commit 1b30660c3b40da557050948ac8635f2dc50c4ee2)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Automerge-Triggered-By: GH:gpshead
Doc/library/typing.rst
Misc/NEWS.d/next/Documentation/2021-12-21-12-45-57.bpo-46120.PE0DmJ.rst [new file with mode: 0644]

index 3adb495ff7933483db53aadd4f2ceaaff8914a41..29bdb80ad22c688bc37f8730f8f672ab0121776c 100644 (file)
@@ -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 (file)
index 0000000..17f6747
--- /dev/null
@@ -0,0 +1 @@
+State that ``|`` is preferred for readability over ``Union`` in the :mod:`typing` docs.