Skip to content
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

False positive: when using optional callable function in lambda after asserting callable is not None #13751

Closed
HiroIshida opened this issue Sep 28, 2022 · 1 comment
Labels
bug mypy got something wrong

Comments

@HiroIshida
Copy link

Bug Report
When function takes optional callable, even though callable is asserted that is is not None, mypy says error: "None" not callable when used in a lambda function.

To Reproduce

from typing import Callable, Optional, List

def example(fun: Optional[Callable[[int], float]]) -> None:
    assert fun is not None
    sorted([1, 2], key=lambda x: fun(x))

Expected Behavior
no warning

Actual Behavior
show the following warning

h-ishida@stonep:~/tmp$ mypy mypy_error.py 
mypy_error.py:6: error: "None" not callable  [misc]

Your Environment

  • Mypy version used: 0.990+dev.9783b46a0062b6acfb8ba58e349e811873fc13f2
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.8.10
@HiroIshida HiroIshida added the bug mypy got something wrong label Sep 28, 2022
@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Sep 28, 2022
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

2 participants