-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Mapping to abs doesn't work #6697
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
This looks like a type inference bug. It is hard to tell what exactly went wrong, but mypy complains because it wanted |
This happened again in #6703, and looks like a fundamental issue, so raising priority to high. |
I was able to recreate it with something more generic -
Output: |
Yes, this is a nice repro. |
Has this been fixed yet? I tried to follow the linked issues but I can't find an obvious answer. I'm running in a similar issue where I'm trying to map set over a list of lists:
And similar to the original issue here, it complains about the first argument to
Is there any practical workaround at this point without having to convert to lambda (that just doesn't make much sense)? |
Just encountered this using mypy 1.4 with
|
I think I got something: It seems
If we look at the definition of
and in our case,
I created a mypy-playground with a minimal reproduction. definitions of the relevant builtinsDefinition of
Definition of
Definition of
|
I don't know much about the internals of |
I just tried examples in this issue and they all seem to work on master if I use |
@ilevkivskyi Does this new inference solve issues like the following?
https://mypy-play.net/?mypy=master&python=3.11&gist=5e696ae12fe41e704d5df7d70ca187c2 |
@randolf-scholz No, because there is no issue. When you define
|
@ilevkivskyi Oh wow, I tried this earlier and it failed, seems I wrote |
I first encountered this issue with Python 3.6.7 and mypy 0.560 from my distribution's repositories, but it also occurs on Python 3.7 and mypy 0.701, and the current master.
This is the code in question:
It works, of course. But running mypy on it raises an error:
If I change it to the following code, there are no errors:
(This is a minimal example, my original code was something like
sum(map(abs, list_of_floats))
.)So, what's the problem here?
int
andfloat
have.__abs__
.The text was updated successfully, but these errors were encountered: