from dataclasses import dataclass
@dataclass
class Box[T]: # T is invariant
item: T
type RefBox[T] = Box[T] # T is invariant
type RefRefBox[T] = RefBox[T] # T is bivariant???
ty 0.0.35 (bc12d1c 2026-05-10) playground 7efc9a615
Evaluation contract
Variance inference for both PEP 695 and legacy generic type aliases must recurse through the alias value rather than treating every alias as bivariant. Preserve covariant, contravariant, invariant, and bivariant results through multi-level and reordered multi-parameter alias chains. Recursive or mutually recursive alias cycles must terminate safely using the existing bivariant cycle fallback.