-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Any inferred when overloaded function called with None argument #3256
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
Comments
Without the It seems to me that this issue is more or less a duplicate #1322. |
This is a special case of #1322. Not sure if it's useful to track these as separate issues. |
I think it's useful to keep it open, just to make sure we don't forget to test this case. |
I think this is working in a reasonable way on master now: mypy reports a 'No overload variant of "f" matches argument type "None"` in strict-optional mode and infers 'int' in no-strict-optional mode. If we add a 'None' fallback, we infer int in both cases. I guess the remaining question is whether or not it would be nice to add a command line flags that tells mypy to do something more stricter then just picking the first match, but I think we already have an issue for that. |
Mypy infers
Any
when calling a precisely typed overloaded function with aNone
argument (without strict optional checking). This is undesirable, since anAny
is silently generated:Not sure what's the right thing to do here -- we can either generate a message that says that the overload target is ambiguous, or infer
Union[int, str]
as the return type.Note that explicitly including a
None
overload variant does not work as a workaround:This is related to #1322.
The text was updated successfully, but these errors were encountered: