Skip to content

Commit 8fb1ab2

Browse files
committed
wip
1 parent 88991ae commit 8fb1ab2

File tree

11 files changed

+80
-603
lines changed

11 files changed

+80
-603
lines changed

crates/ty_python_semantic/resources/mdtest/generics/pep695/variance.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,11 @@ static_assert(is_equivalent_to(C[A], C[A]))
315315
static_assert(is_equivalent_to(C[B], C[B]))
316316
static_assert(is_equivalent_to(C[B], C[A]))
317317
static_assert(is_equivalent_to(C[A], C[B]))
318-
static_assert(is_equivalent_to(C[A], C[Any]))
319-
static_assert(is_equivalent_to(C[B], C[Any]))
320-
static_assert(is_equivalent_to(C[Any], C[A]))
321-
static_assert(is_equivalent_to(C[Any], C[B]))
318+
319+
static_assert(not is_equivalent_to(C[A], C[Any]))
320+
static_assert(not is_equivalent_to(C[B], C[Any]))
321+
static_assert(not is_equivalent_to(C[Any], C[A]))
322+
static_assert(not is_equivalent_to(C[Any], C[B]))
322323

323324
static_assert(not is_equivalent_to(D[A], C[A]))
324325
static_assert(not is_equivalent_to(D[B], C[B]))

crates/ty_python_semantic/resources/mdtest/protocols.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,10 +1147,10 @@ static_assert(
11471147
)
11481148
)
11491149

1150-
static_assert(not is_equivalent_to(GenericProto[str], GenericProto[int]))
1151-
static_assert(not is_equivalent_to(GenericProto[str], LegacyGenericProto[int]))
1152-
static_assert(not is_equivalent_to(GenericProto, GenericProto[int]))
1153-
static_assert(not is_equivalent_to(LegacyGenericProto, LegacyGenericProto[int]))
1150+
static_assert(not is_equivalent_to(GenericProto[str], GenericProto[int])) # error: [static-assert-error]
1151+
static_assert(not is_equivalent_to(GenericProto[str], LegacyGenericProto[int])) # error: [static-assert-error]
1152+
static_assert(not is_equivalent_to(GenericProto, GenericProto[int])) # error: [static-assert-error]
1153+
static_assert(not is_equivalent_to(LegacyGenericProto, LegacyGenericProto[int])) # error: [static-assert-error]
11541154
```
11551155

11561156
## Intersections of protocols
@@ -1543,8 +1543,7 @@ from ty_extensions import is_equivalent_to
15431543
class HasMutableXAttr(Protocol):
15441544
x: int
15451545

1546-
# TODO: should pass
1547-
static_assert(is_equivalent_to(HasMutableXAttr, HasMutableXProperty)) # error: [static-assert-error]
1546+
static_assert(is_equivalent_to(HasMutableXAttr, HasMutableXProperty))
15481547

15491548
static_assert(is_subtype_of(HasMutableXAttr, HasXProperty))
15501549
static_assert(is_assignable_to(HasMutableXAttr, HasXProperty))
@@ -1810,9 +1809,7 @@ class P4(Protocol):
18101809
def z(self, value: int) -> None: ...
18111810

18121811
static_assert(is_equivalent_to(P1, P2))
1813-
1814-
# TODO: should pass
1815-
static_assert(is_equivalent_to(P3, P4)) # error: [static-assert-error]
1812+
static_assert(is_equivalent_to(P3, P4))
18161813
```
18171814

18181815
As with protocols that only have non-method members, this also holds true when they appear in
@@ -1823,9 +1820,7 @@ class A: ...
18231820
class B: ...
18241821

18251822
static_assert(is_equivalent_to(A | B | P1, P2 | B | A))
1826-
1827-
# TODO: should pass
1828-
static_assert(is_equivalent_to(A | B | P3, P4 | B | A)) # error: [static-assert-error]
1823+
static_assert(is_equivalent_to(A | B | P3, P4 | B | A))
18291824
```
18301825

18311826
## Narrowing of protocols
@@ -2106,8 +2101,6 @@ class Bar(Protocol):
21062101
@property
21072102
def x(self) -> "Bar": ...
21082103

2109-
# TODO: this should pass
2110-
# error: [static-assert-error]
21112104
static_assert(is_equivalent_to(Foo, Bar))
21122105

21132106
T = TypeVar("T", bound="TypeVarRecursive")

0 commit comments

Comments
 (0)