Gradual constraints are not propagated to nested type variables
Author: ibraheemdevCreated Sep 16, 2026Updated Sep 16, 2026
Labelsbuggenerics
Assignability checks of the form Any <: tuple[T] currently eagerly evaluate to true without enforcing any constraints on the nested type variable T. This can lead to the constraint solver falling back to Unknown despite inference evidence being present.
from typing import Any
def f[T](x: tuple[T]) -> T:
return x[0]
def _(x: Any):
reveal_type(f(x)) # revealed: UnknownNote that Any <: tuple[T] implies that the gradual type Any materializes to some subtype of tuple, i.e., tuple[Any], and hence we should infer a lower bound of Any on T to preserve graduality.
Source: astral-sh/ty