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

Skip to content

Commit e93b06a

Browse files
committed
Hopefully clarify the difference between Optional[t] and an optional argument.
1 parent 48a583b commit e93b06a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Doc/library/typing.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ The module defines the following classes, functions and decorators:
286286

287287
``Optional[X]`` is equivalent to ``Union[X, type(None)]``.
288288

289+
Note that this is not the same concept as an optional argument,
290+
which is one that has a default. An optional argument with a
291+
default needn't use the ``Optional`` qualifier on its type
292+
annotation (although it is inferred if the default is ``None``).
293+
A mandatory argument may still have an ``Optional`` type if an
294+
explicit value of ``None`` is allowed.
295+
289296
.. class:: Tuple
290297

291298
Tuple type; ``Tuple[X, Y]`` is the is the type of a tuple of two items

0 commit comments

Comments
 (0)