Open KotlinIsland opened 4 months ago
def f(fn: Callable[[int], int]):... f(lambda i: i) # no error, int @f def foo(i): # error return i # Unknown
from typing import Callable from basedtyping import P, T def copy_signature(fn: Callable[P, T]) -> Callable[[Callable[P, T]], Callable[P, T]]: ... def f(a: int) -> str: return str(a) @copy_signature(f) def g(a): reveal_type(a) # Unknown return "" reveal_type(g) # (int) -> str
The function should act like a lambda here and infer the types of the parameters from the surrounding context
copy_signature(f, lambda a: "") # correctly infers
real life:
The function should act like a lambda here and infer the types of the parameters from the surrounding context