Skip to content

min key signature deduced incorrectly #11675

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

Closed
ikonst opened this issue Dec 7, 2021 · 2 comments
Closed

min key signature deduced incorrectly #11675

ikonst opened this issue Dec 7, 2021 · 2 comments
Labels
bug mypy got something wrong

Comments

@ikonst
Copy link
Contributor

ikonst commented Dec 7, 2021

from typing import *

lst = [1, 2, 3]

ok = min(lst, key=lambda val: val * 2, default=None)
also_ok: Optional[int] = min(lst, key=lambda val: val * 2)
not_ok: Optional[int] = min(lst, key=lambda val: val * 2, default=None)

results in:

main.py:7: error: Unsupported operand types for * ("None" and "int")
main.py:7: note: Left operand is of type "Optional[int]"
Found 1 error in 1 file (checked 1 source file)

https://mypy-play.net/?mypy=latest&python=3.10&gist=d1b9d6d966eba554375172c9826f8d6e

@ikonst ikonst added the bug mypy got something wrong label Dec 7, 2021
@ikonst
Copy link
Contributor Author

ikonst commented Dec 7, 2021

OK, seems to be a dup of #6692

@ikonst
Copy link
Contributor Author

ikonst commented Dec 7, 2021

Itself a dup of #5874

@ikonst ikonst closed this as completed Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant