From: Guido van Rossum Date: Wed, 10 Feb 2016 17:48:58 +0000 (-0800) Subject: Hopefully clarify the difference between Optional[t] and an optional argument. X-Git-Tag: v3.6.0a1~620^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e93b06a0a3255026802be19de249b3fdfe955b96;p=python Hopefully clarify the difference between Optional[t] and an optional argument. --- diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 41f594ecc4..12b5490b66 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -286,6 +286,13 @@ The module defines the following classes, functions and decorators: ``Optional[X]`` is equivalent to ``Union[X, type(None)]``. + 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. + .. class:: Tuple Tuple type; ``Tuple[X, Y]`` is the is the type of a tuple of two items