diff --git a/crates/ty_python_semantic/src/types/constraints.rs b/crates/ty_python_semantic/src/types/constraints.rs index b31aa3bc37..3c32c059d2 100644 --- a/crates/ty_python_semantic/src/types/constraints.rs +++ b/crates/ty_python_semantic/src/types/constraints.rs @@ -2655,14 +2655,18 @@ impl<'db> SequentMap<'db> { // (CL ≤ C ≤ pivot) ∧ (pivot ≤ B ≤ BU) → (CL ≤ C ≤ B) (constrained_lower, constrained_upper) - if constrained_upper == bound_constraint.lower(db) => + if constrained_upper == bound_constraint.lower(db) + && !constrained_upper.is_never() + && !constrained_upper.is_object() => { (constrained_lower, Type::TypeVar(bound_typevar)) } // (pivot ≤ C ≤ CU) ∧ (BL ≤ B ≤ pivot) → (B ≤ C ≤ CU) (constrained_lower, constrained_upper) - if constrained_lower == bound_constraint.upper(db) => + if constrained_lower == bound_constraint.upper(db) + && !constrained_lower.is_never() + && !constrained_lower.is_object() => { (Type::TypeVar(bound_typevar), constrained_upper) }