File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -990,10 +990,18 @@ The module defines the following classes, functions and decorators:
990
990
991
991
Note that this is not the same concept as an optional argument,
992
992
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
+ ...
997
1005
998
1006
.. data :: Tuple
999
1007
You can’t perform that action at this time.
0 commit comments