From 6c03643a0b6761325fd7e80236e82e75e01855af Mon Sep 17 00:00:00 2001 From: Douglas Creager Date: Thu, 6 Nov 2025 11:06:26 -0500 Subject: [PATCH] connective checks work for all typevars --- crates/ty_python_semantic/src/types.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index 62a50e9c2d..75138bfbc0 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -1818,21 +1818,16 @@ impl<'db> Type<'db> { // However, there is one exception to this general rule: for any given typevar `T`, // `T` will always be a subtype of any union containing `T`. // A similar rule applies in reverse to intersection types. - (Type::TypeVar(bound_typevar), Type::Union(union)) - if !bound_typevar.is_inferable(db, inferable) - && union.elements(db).contains(&self) => + (Type::TypeVar(_), Type::Union(union)) if union.elements(db).contains(&self) => { + ConstraintSet::from(true) + } + (Type::Intersection(intersection), Type::TypeVar(_)) + if intersection.positive(db).contains(&target) => { ConstraintSet::from(true) } - (Type::Intersection(intersection), Type::TypeVar(bound_typevar)) - if !bound_typevar.is_inferable(db, inferable) - && intersection.positive(db).contains(&target) => - { - ConstraintSet::from(true) - } - (Type::Intersection(intersection), Type::TypeVar(bound_typevar)) - if !bound_typevar.is_inferable(db, inferable) - && intersection.negative(db).contains(&target) => + (Type::Intersection(intersection), Type::TypeVar(_)) + if intersection.negative(db).contains(&target) => { ConstraintSet::from(false) }