basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

infer polymorphism

Open KotlinIsland opened this issue 1 year ago • 0 comments

def f(a):  # def f[T](a: T) -> T
    return a

def find(data: list, predicate: "(...) -> ..."):  # find[T](data: list[T], predicate: (T) -> T) -> T
    for item in data:
        if predicate(item):
            return item
     raise ValueError

probs many more cases, and maybe we can use ... in the type position to mean "this must be inferable"

KotlinIsland avatar Apr 24 '24 03:04 KotlinIsland