Closed as not planned
Description
Bug Report
Type-checking a method with a typed argument (typed to any regular type) with None
as default yields no error.
I would expect this to be a type-error - as the real type of other
in the below case is Optional[str]
.
To Reproduce
def random_function(value: str, other: str = None):
pass
Playground:
https://mypy-play.net/?mypy=master&python=3.10&gist=c9a5da3dab27e76281498b25ca3a5e4d
Expected Behavior
Raising problematic default value, causing either a change in default, or a re-typing to Optional[str]
.
Actual Behavior
No error from mypy
Interestingly, pyright does properly detect this and raises the following error (this is how i discovered this bug).
error: Expression of type "None" cannot be assigned to parameter of type "str"
Type "None" cannot be assigned to type "str" (reportGeneralTypeIssues)
Your Environment
- Mypy version used: 0.950
- Mypy command-line flags: /
- Mypy configuration options from
mypy.ini
(and other config files): / - Python version used: 3.10