Skip to content

Commit 8ca60d5

Browse files
committed
add mdtest for mutually-recursive protocols
1 parent 59d0231 commit 8ca60d5

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
@@ -1729,6 +1729,21 @@ def _(r: Recursive):
17291729
reveal_type(r.method(r).callable1(1).direct.t[1][1]) # revealed: Recursive
17301730
```
17311731

1732+
### Mutually-recursive protocols
1733+
1734+
```py
1735+
from typing import Protocol
1736+
from ty_extensions import is_equivalent_to, static_assert
1737+
1738+
class Foo(Protocol):
1739+
x: "Bar"
1740+
1741+
class Bar(Protocol):
1742+
x: Foo
1743+
1744+
static_assert(is_equivalent_to(Foo, Bar))
1745+
```
1746+
17321747
### Regression test: narrowing with self-referential protocols
17331748

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

0 commit comments

Comments
 (0)