]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46120: State that `|` is preferred over `Union` (GH-30222)
authorNikita Sobolev <mail@sobolevn.me>
Fri, 24 Dec 2021 21:36:09 +0000 (00:36 +0300)
committerGitHub <noreply@github.com>
Fri, 24 Dec 2021 21:36:09 +0000 (13:36 -0800)
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
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 727941b57b547b676740e846e9f32ee6ee752b08..08b59d84246f8d7877a32df4d8767ba04611f100 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.