Closed
Description
Very similar to #1983 but still happens with mypy 1.0
Bug Report
To Reproduce
from typing import Callable, Any
from random import randrange
def test(x: Callable[[Any], None]): pass
def a(*y: Any) -> None: pass
def b(y: str) -> None: pass
test(a if randrange(2) else b)
https://mypy-play.net/?mypy=master&python=3.11&gist=a5b887f28bebad92989797587f29a123
Expected Behavior
The code type checks successfully.
Actual Behavior
main.py:6: error: Argument 1 to "test" has incompatible type "function"; expected "Callable[[Any], None]" [arg-type]
Your Environment
- Mypy version used: tested with 0.790, 1.0.0, and master
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: tested with 3.7 and 3.11