@@ -1077,7 +1077,7 @@ def test_object(x: object) -> None:
1077
1077
case Callable() as fn:
1078
1078
reveal_type(fn) # N: Revealed type is "def (*Any, **Any) -> Any"
1079
1079
1080
- def test_intfun (x: Callable[[int], int]) -> None:
1080
+ def test_impl (x: Callable[[int], int]) -> None:
1081
1081
match x:
1082
1082
case Callable() as fn:
1083
1083
reveal_type(fn) # N: Revealed type is "def (builtins.int) -> builtins.int"
@@ -1087,6 +1087,26 @@ def test_intfun(x: Callable[[int], int]) -> None:
1087
1087
from typing import Any, Callable
1088
1088
from typing_extensions import Protocol, runtime_checkable
1089
1089
1090
+ @runtime_checkable
1091
+ class FnProto(Protocol):
1092
+ def __call__(self, x: int, /) -> object: ...
1093
+
1094
+ def test_object(x: object) -> None:
1095
+ match x:
1096
+ case FnProto() as fn:
1097
+ reveal_type(fn) # N: Revealed type is "__main__.FnProto"
1098
+
1099
+ def test_impl(x: Callable[[int], int]) -> None:
1100
+ match x:
1101
+ case FnProto() as fn:
1102
+ reveal_type(fn) # N: Revealed type is "def (builtins.int) -> builtins.int"
1103
+
1104
+ [builtins fixtures/dict.pyi]
1105
+
1106
+ [case testMatchClassPatternAnyCallableProtocol]
1107
+ from typing import Any, Callable
1108
+ from typing_extensions import Protocol, runtime_checkable
1109
+
1090
1110
@runtime_checkable
1091
1111
class AnyCallable(Protocol):
1092
1112
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
@@ -1096,7 +1116,7 @@ def test_object(x: object) -> None:
1096
1116
case AnyCallable() as fn:
1097
1117
reveal_type(fn) # N: Revealed type is "__main__.AnyCallable"
1098
1118
1099
- def test_intfun (x: Callable[[int], int]) -> None:
1119
+ def test_impl (x: Callable[[int], int]) -> None:
1100
1120
match x:
1101
1121
case AnyCallable() as fn:
1102
1122
reveal_type(fn) # N: Revealed type is "def (builtins.int) -> builtins.int"
0 commit comments