Skip to content

Commit b02fd49

Browse files
committed
add mdtest for mutually-recursive protocols
1 parent 072122b commit b02fd49

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

crates/ty_python_semantic/resources/mdtest/protocols.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,21 @@ def _(r: Recursive):
15771577
reveal_type(r.method(r).callable1(1).direct.t[1][1]) # revealed: Recursive
15781578
```
15791579

1580+
### Mutually-recursive protocols
1581+
1582+
```py
1583+
from typing import Protocol
1584+
from ty_extensions import is_equivalent_to, static_assert
1585+
1586+
class Foo(Protocol):
1587+
x: "Bar"
1588+
1589+
class Bar(Protocol):
1590+
x: Foo
1591+
1592+
static_assert(is_equivalent_to(Foo, Bar))
1593+
```
1594+
15801595
### Regression test: narrowing with self-referential protocols
15811596

15821597
This snippet caused us to panic on an early version of the implementation for protocols.

0 commit comments

Comments
 (0)