Closed
Description
Mypy complains about the following code even though it should be valid:
from typing import typevar, overload, Function
T = typevar('T', values=(int, str))
def f(x: T) -> None:
m(g, x) # Error: Argument 1 to "m" has incompatible type functionlike; expected Function[["str"] -> "int"]
A = typevar('A')
R = typevar('R')
def m(f: Function[[A], R], it: A) -> None: pass
@overload
def g(x: int) -> int: return x
@overload
def g(x: str) -> str: return x