Closed as not planned
Description
Bug Report
Quoted from PEP 484:
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 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.
To Reproduce
- input the code snippet:
def handle_employee(e: Employee = None): ...
- run
mypy handle_employee.py
Expected Behavior
mypy show a warning or an error like this:
error: Incompatible default for argument "e" (default has type "None", argument has type "Employee")
Actual Behavior
No warning or error is given.
Your Environment
- Mypy version used: 0.960
- Mypy command-line flags: no flag
- Mypy configuration options from
mypy.ini
(and other config files): I don't set it. - Python version used: 3.10.4
- Operating system and version: Windows 11