Skip to content

Commit dba1e0d

Browse files
author
Guido van Rossum
committed
In a stub, default values may be "...". Closes issue #57.
1 parent f6c17dd commit dba1e0d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pep-0484.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,22 @@ and this is also the suggested default when the program is being
660660
type-checked.
661661

662662

663+
Default argument values
664+
-----------------------
665+
666+
In stubs it may be useful to declare an argument as having a default
667+
without specifying the actual default value. For example::
668+
669+
def foo(x: AnyStr, y: AnyStr = ...) -> AnyStr: ...
670+
671+
What should the default value look like? Any of the options ``""``,
672+
``b""`` or ``None`` fails to satisfy the type constraint (actually,
673+
``None`` will *modify* the type to become ``Optional[AnyStr]``).
674+
675+
In such cases the default value may be specified as a literal
676+
ellipsis, i.e. the above example is literally what you would write.
677+
678+
663679
Compatibility with other uses of function annotations
664680
=====================================================
665681

0 commit comments

Comments
 (0)