Skip to content

Commit 15740d3

Browse files
Do not require type checkers to treat a None default specially
Following discussion in python/typing#275, there is a consensus that it is better to require optional types to be made explicit. This PR changes the wording of PEP 484 to allow, but not require, type checkers to treat a None default as implicitly making an argument Optional.
1 parent 7ef0449 commit 15740d3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pep-0484.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,15 +984,16 @@ for example, the above is equivalent to::
984984

985985
def handle_employee(e: Optional[Employee]) -> None: ...
986986

987-
An optional type is also automatically assumed when the default value is
988-
``None``, for example::
987+
Type checkers may also automatically assume an optional type when the
988+
default value is ``None``, for example::
989989

990990
def handle_employee(e: Employee = None): ...
991991

992-
This is equivalent to::
992+
This may be treated as equivalent to::
993993

994994
def handle_employee(e: Optional[Employee] = None) -> None: ...
995995

996+
Type checkers may also require the optional type to be made explicit.
996997

997998
Support for singleton types in unions
998999
-------------------------------------

0 commit comments

Comments
 (0)