aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rittau <srittau@rittau.biz>2022-04-05 19:22:31 +0200
committerGitHub <noreply@github.com>2022-04-05 19:22:31 +0200
commitf9d318138fcec1f9724ee1808aeff3ed1bf976a5 (patch)
tree667a672cb2110635f54bdf2b213b69e2e3d918dc
parent5eed34c3daf3b38edf4d1246b3c063f38579cbe7 (diff)
downloadtyping-f9d318138fcec1f9724ee1808aeff3ed1bf976a5.tar.gz
Don't list specific bugs with union short-hand syntax (#1119)
-rw-r--r--docs/source/stubs.rst12
1 files changed, 2 insertions, 10 deletions
diff --git a/docs/source/stubs.rst b/docs/source/stubs.rst
index 539e8cb..ffd6c9b 100644
--- a/docs/source/stubs.rst
+++ b/docs/source/stubs.rst
@@ -193,15 +193,12 @@ Unions
------
Declaring unions with ``Union`` and ``Optional`` is supported by all
-type checkers. With the exception of type aliases [#ts-4819]_, the shorthand syntax
+type checkers. With a few exceptions [#ts-4819]_, the shorthand syntax
is also supported::
def foo(x: int | str) -> int | None: ... # recommended
def foo(x: Union[int, str]) -> Optional[int]: ... # ok
- TYPE_ALIAS = Union[int, str] # ok
- TYPE_ALIAS = int | str # does not work with all type checkers
-
Module Level Attributes
-----------------------
@@ -817,8 +814,7 @@ Shorthand Syntax
Where possible, use shorthand syntax for unions instead of
``Union`` or ``Optional``. ``None`` should be the last
-element of an union. See the Unions_ section for cases where
-using the shorthand syntax is not possible.
+element of an union.
Yes::
@@ -831,10 +827,6 @@ No::
def bar(x: Optional[str]) -> Optional[int]: ...
def baz(x: None | str) -> None: ...
-But the following is still necessary::
-
- TYPE_ALIAS: TypeAlias = Optional[Union[str, int]]
-
Module Level Attributes
-----------------------