mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 21:40:51 -05:00
[ty] Fix property-tests (#22229)
This commit is contained in:
@@ -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]]))
|
||||
```
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user