summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2018-08-05 16:38:04 (GMT)
committerIvan Levkivskyi <levkivskyi@gmail.com>2018-08-05 16:38:04 (GMT)
commit336c945858055059a65134d4c501a85037d70d99 (patch)
treed1cb3eba05589bd6bc58b81cebc043f27d7d8788 /Doc
parent87e59ac11ee074b0dc1bc864c74fac0660b27f6e (diff)
downloadcpython-336c945858055059a65134d4c501a85037d70d99.zip
cpython-336c945858055059a65134d4c501a85037d70d99.tar.gz
cpython-336c945858055059a65134d4c501a85037d70d99.tar.bz2
bpo-34336: Don't promote possibility to leave out typing.Optional (#8677)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/typing.rst16
1 files changed, 12 insertions, 4 deletions
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 91d10e3..23a6415 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -990,10 +990,18 @@ The module defines the following classes, functions and decorators:
Note that this is not the same concept as an optional argument,
which is one that has a default. An optional argument with a
- default needn't use the ``Optional`` qualifier on its type
- annotation (although it is inferred if the default is ``None``).
- A mandatory argument may still have an ``Optional`` type if an
- explicit value of ``None`` is allowed.
+ default does not require the ``Optional`` qualifier on its type
+ annotation just because it is optional. For example::
+
+ def foo(arg: int = 0) -> None:
+ ...
+
+ On the other hand, if an explicit value of ``None`` is allowed, the
+ use of ``Optional`` is appropriate, whether the argument is optional
+ or not. For example::
+
+ def foo(arg: Optional[int] = None) -> None:
+ ...
.. data:: Tuple