Skip to content

Commit d388ec9

Browse files
added test for plain protocols
1 parent a5c4ebe commit d388ec9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test-data/unit/check-python310.test

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,30 @@ def test_intfun(x: Callable[[int], int]) -> None:
11031103

11041104
[builtins fixtures/dict.pyi]
11051105

1106+
1107+
[case testMatchClassPatternProtocol]
1108+
from typing import Any
1109+
from typing_extensions import Protocol, runtime_checkable
1110+
1111+
class Proto(Protocol):
1112+
def foo(self, x: int, /) -> object: ...
1113+
1114+
class Impl:
1115+
def foo(self, x: object, /) -> int: ...
1116+
1117+
def test_object(x: object) -> None:
1118+
match x:
1119+
case Proto() as y:
1120+
reveal_type(y) # N: Revealed type is "__main__.Proto"
1121+
1122+
def test_impl(x: Impl) -> None:
1123+
match x:
1124+
case Proto() as y:
1125+
reveal_type(y) # N: Revealed type is "__main__.Impl"
1126+
1127+
[builtins fixtures/dict.pyi]
1128+
1129+
11061130
[case testMatchClassPatternNestedGenerics]
11071131
# From cpython test_patma.py
11081132
x = [[{0: 0}]]

0 commit comments

Comments
 (0)