Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1816dfe

Browse files
committed
Issue #28073: Improve wording around None. Michael Lee.
1 parent cc66a65 commit 1816dfe

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Doc/library/typing.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Type aliases are useful for simplifying complex type signatures. For example::
5959
servers: List[Tuple[Tuple[str, int], Dict[str, str]]]) -> None:
6060
...
6161

62+
Note that ``None`` as a type hint is a special case and is replaced by
63+
``type(None)``.
64+
6265
NewType
6366
-------
6467

@@ -148,7 +151,6 @@ For example::
148151
It is possible to declare the return type of a callable without specifying
149152
the call signature by substituting a literal ellipsis
150153
for the list of arguments in the type hint: ``Callable[..., ReturnType]``.
151-
``None`` as a type hint is a special case and is replaced by ``type(None)``.
152154

153155
Generics
154156
--------
@@ -443,7 +445,7 @@ The module defines the following classes, functions and decorators:
443445

444446
Optional type.
445447

446-
``Optional[X]`` is equivalent to ``Union[X, type(None)]``.
448+
``Optional[X]`` is equivalent to ``Union[X, None]``.
447449

448450
Note that this is not the same concept as an optional argument,
449451
which is one that has a default. An optional argument with a

0 commit comments

Comments
 (0)