File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -990,10 +990,18 @@ The module defines the following classes, functions and decorators:
990990
991991 Note that this is not the same concept as an optional argument,
992992 which is one that has a default. An optional argument with a
993- default needn't use the ``Optional `` qualifier on its type
994- annotation (although it is inferred if the default is ``None ``).
995- A mandatory argument may still have an ``Optional `` type if an
996- explicit value of ``None `` is allowed.
993+ default does not require the ``Optional `` qualifier on its type
994+ annotation just because it is optional. For example::
995+
996+ def foo(arg: int = 0) -> None:
997+ ...
998+
999+ On the other hand, if an explicit value of ``None `` is allowed, the
1000+ use of ``Optional `` is appropriate, whether the argument is optional
1001+ or not. For example::
1002+
1003+ def foo(arg: Optional[int] = None) -> None:
1004+ ...
9971005
9981006.. data :: Tuple
9991007
You can’t perform that action at this time.
0 commit comments