diff --git a/crates/ty_python_semantic/resources/mdtest/regression/2236_tuple_is_disjoint.md b/crates/ty_python_semantic/resources/mdtest/regression/2236_tuple_is_disjoint.md new file mode 100644 index 0000000000..91f695655e --- /dev/null +++ b/crates/ty_python_semantic/resources/mdtest/regression/2236_tuple_is_disjoint.md @@ -0,0 +1,20 @@ +# Tuple pair is assignable to their union + +Regression test for . + +```toml +[environment] +python-version = "3.11" +``` + +```py +from types import FunctionType +from ty_extensions import Not, AlwaysTruthy, is_subtype_of, static_assert, is_disjoint_from + +class Meta(type): ... +class F(metaclass=Meta): ... + +static_assert(not is_subtype_of(tuple[FunctionType, type[F]], Not[tuple[*tuple[AlwaysTruthy, ...], Meta]])) +static_assert(not is_subtype_of(Not[tuple[*tuple[AlwaysTruthy, ...], Meta]], tuple[FunctionType, type[F]])) +static_assert(is_disjoint_from(tuple[FunctionType, type[F]], Not[tuple[*tuple[AlwaysTruthy, ...], Meta]])) +``` diff --git a/crates/ty_python_semantic/src/types/tuple.rs b/crates/ty_python_semantic/src/types/tuple.rs index f1e130503e..109b27dff6 100644 --- a/crates/ty_python_semantic/src/types/tuple.rs +++ b/crates/ty_python_semantic/src/types/tuple.rs @@ -1542,7 +1542,8 @@ impl<'db> Tuple> { { if rev { a.iter() - .zip(b) + .rev() + .zip(b.iter().rev()) .when_any(db, |(self_element, other_element)| { self_element.is_disjoint_from_impl( db, @@ -1554,8 +1555,7 @@ impl<'db> Tuple> { }) } else { a.iter() - .rev() - .zip(b.iter().rev()) + .zip(b) .when_any(db, |(self_element, other_element)| { self_element.is_disjoint_from_impl( db,