-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function default arguments false negative #12869
Comments
The original PEP 484 indicated that when a parameter had a |
I'm personally more in favor of the implicit behavior (mypy default) - but struggled to find the "proper" flag for it while opening the issue. |
@erictraut is right. The specific flag for this behavior is We already have issue #9091 about changing the default, so closing this as a duplicate. |
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 isOptional[str]
.To Reproduce
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).
Your Environment
mypy.ini
(and other config files): /The text was updated successfully, but these errors were encountered: