-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Mypy blows up sometimes with bad reverse method #5337
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
Heh, that sounds like a pretty simple bug. We clearly should use a more sophisticated check than checking for exactly 2 arguments. Maybe you can give it a try yourself? |
Sure, I can try! |
After thinking about it some more, I think this is actually a false positive; having a default argument should actually be ok. (Rereading what you wrote above, I think you already realized this.) Running the following code works: class Foo:
def __radd__(self, other: object, other2: object = None) -> 'Foo':
return self
f = Foo()
g = 1 + f Would assert is_subtype(reverse_type, method_type) make sense as a better check here? |
When I run mypy (no special arguments) on the following code (with
--show-traceback
):it fails with this error:
The expected behavior should be the same as in the following, similar example:
which gracefully fails with the message:
The text was updated successfully, but these errors were encountered: