[ty] Fix property-tests (#22229)

This commit is contained in:
Micha Reiser
2025-12-28 09:58:48 +01:00
committed by GitHub
parent dea48ecef0
commit d5c39d3f9f
2 changed files with 23 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
# Tuple pair is assignable to their union
Regression test for <https://github.com/astral-sh/ty/issues/2236>.
```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]]))
```

View File

@@ -1542,7 +1542,8 @@ impl<'db> Tuple<Type<'db>> {
{
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<Type<'db>> {
})
} else {
a.iter()
.rev()
.zip(b.iter().rev())
.zip(b)
.when_any(db, |(self_element, other_element)| {
self_element.is_disjoint_from_impl(
db,