-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
__lt__ and __gt__ should always be allowed to have return type bool #1101
Comments
Example:
|
This guards against a weird corner case that could cause a wrong type to be inferred. The example in the comment near the linked code gives some context (though it's not a complete example). It originates from my PhD research where type soundness was a major thing. As the goals of mypy have shifted, this check doesn't make sense any more. I'll just remove it. |
WIP: Rip out offending error messages for issue #1101.
It seems that mypy doesn't allow
If I change this to
and when I try following the suggestion, I get a runtime error:
|
Please use a new issue for such feedback. The root cause seems to be that |
When the argument to
__lt__
or__gt__
(or probably others) has typeAny
, mypy insists that the return type is alsoAny
. (This is hardcoded: https://github.com/JukkaL/mypy/blob/master/mypy/checker.py#L621-L622 )Why is this? Is it related to #363?
It's inconvenient.
The text was updated successfully, but these errors were encountered: