Inconsistent handling of unannotated lambda expressions
Author: ibraheemdevCreated Sep 17, 2026Updated Sep 17, 2026
Labelsbuggenericscallablescycles
There are a couple of places where we treat an unannotated lambda expression differently than a function with unannotated parameters, despite both types having the same callable signature.
from collections.abc import Callable
def consume[T](value: T, callback: Callable[[T], object]) -> None:
callback(value)
def f1(x) -> int:
return 0
f2 = lambda x: 0
consume(f1, lambda f: f()) # error: [missing-argument]
consume(f2, lambda f: f()) # okDuring cyclic lambda inference, we infer a marker type for unannotated lambda parameters, which is ignored during generic call inference. However, the marker type is never finalized and so leaks into the final inferred type of the lambda, causing imprecise inference when the resulting lambda is used in a generic call.
Source: astral-sh/ty