-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
mypy throws error using min with a key function specified #1150
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No 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? No Sign in to your account
Comments
The stub handles this case, but mypy complains because it doesn't consider keyword argument names when picking an overload variant. This is a vaguely known issue that has been around for a long time, but I can't find a duplicate tracker issue. |
Looks like this also affects sorted; reproducer: |
Tim: I don't believe sorted() has the same problem -- it's not
overloaded. Can you file that (with the error you get) as a separate
issue?
|
The PY3 overloads for min() currently look like this:
(max() and PY2 are similar.)
My tests are as follows:
Jukka, are you okay if I commit that to typeshed? |
Jukka, can you look at python/typeshed#58 ? It fixes the issue for me. |
Ok created #1160 for the sorted issue |
Closed by 6a47ac7. |
Sorry, I'm going to have to revert the fix, I think Jukka's right and this requires a fix to mypy. |
I'm looking at fixing overload resolution. |
Reproducer:
min([1, 2], key = lambda x: -x)
The text was updated successfully, but these errors were encountered: