-
-
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
Cannot infer type argument when mixing int and float #2035
Comments
Just out of curiosity: What is mypy supposed to do, when having
and a call
Should it try to "promote" either A to B or B to A? Or should it try to find a common base class between the two? Or would the magic that makes bisect_left work not actually apply for the non-sequence case? |
It looks for a value for The non-sequence case should work already -- it's the sequence case that is broken. |
any way of specifying type arguments to a function? class A: pass
class B(A): pass
bisect_left[A]([B()], A()) # same error |
Not directly, but you can use from typing import cast
class A: pass
class B(A): pass
bisect_left([cast(A, B())], A()) # ok |
Increasing priority since there was a user question that boils down to this issue and the fix seems simple. |
Fixes python#2035. Conflicts: test-data/unit/check-inference-context.test
Mypy complains about this code, even though it looks fine to me:
This doesn't seem to be related to promotions, as it also happens with user-defined types:
The text was updated successfully, but these errors were encountered: