Skip to content

Commit 1a73410

Browse files
committed
wip
1 parent 5b54717 commit 1a73410

File tree

11 files changed

+86
-609
lines changed

11 files changed

+86
-609
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))
@@ -1835,9 +1834,7 @@ class P4(Protocol):
18351834
def z(self, value: int) -> None: ...
18361835

18371836
static_assert(is_equivalent_to(P1, P2))
1838-
1839-
# TODO: should pass
1840-
static_assert(is_equivalent_to(P3, P4)) # error: [static-assert-error]
1837+
static_assert(is_equivalent_to(P3, P4))
18411838
```
18421839

18431840
As with protocols that only have non-method members, this also holds true when they appear in
@@ -1848,9 +1845,7 @@ class A: ...
18481845
class B: ...
18491846

18501847
static_assert(is_equivalent_to(A | B | P1, P2 | B | A))
1851-
1852-
# TODO: should pass
1853-
static_assert(is_equivalent_to(A | B | P3, P4 | B | A)) # error: [static-assert-error]
1848+
static_assert(is_equivalent_to(A | B | P3, P4 | B | A))
18541849
```
18551850

18561851
## Narrowing of protocols
@@ -2131,8 +2126,6 @@ class Bar(Protocol):
21312126
@property
21322127
def x(self) -> "Bar": ...
21332128

2134-
# TODO: this should pass
2135-
# error: [static-assert-error]
21362129
static_assert(is_equivalent_to(Foo, Bar))
21372130

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

0 commit comments

Comments
 (0)