Skip to content

Commit

Permalink
PEP 484: Do not require type checkers to treat a None default special…
Browse files Browse the repository at this point in the history
…ly (#689)

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 encourage
type checkers to treat a None default as implicitly making an argument Optional.
  • Loading branch information
JelleZijlstra authored and gvanrossum committed Jul 10, 2018
1 parent 8a3ed36 commit 0630155
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pep-0484.txt
Original file line number Diff line number Diff line change
Expand Up @@ -984,15 +984,17 @@ 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::
A past version of this PEP allowed type checkers to assume an optional
type when the default value is ``None``, as in this code::

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

This is equivalent to::
This would have been treated as equivalent to::

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

This is no longer the recommended behavior. Type checkers should move
towards requiring the optional type to be made explicit.

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

0 comments on commit 0630155

Please sign in to comment.