Skip to content

Commit

Permalink
Do not require type checkers to treat a None default specially
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JelleZijlstra authored Jul 1, 2018
1 parent 7ef0449 commit 15740d3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pep-0484.txt
Original file line number Diff line number Diff line change
Expand Up @@ -984,15 +984,16 @@ for example, the above is equivalent to::

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

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

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

This is equivalent to::
This may be treated as equivalent to::

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

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

Support for singleton types in unions
-------------------------------------
Expand Down

0 comments on commit 15740d3

Please sign in to comment.