Skip to content

Commit c4471a1

Browse files
improved testMatchClassPatternCallable with extra check
1 parent c5d34c9 commit c4471a1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test-data/unit/check-python310.test

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,15 +1072,23 @@ match m:
10721072
[case testMatchClassPatternCallable]
10731073
from typing import Callable
10741074

1075+
class FnImpl:
1076+
def __call__(self, x: object, /) -> int: ...
1077+
10751078
def test_object(x: object) -> None:
10761079
match x:
10771080
case Callable() as fn:
10781081
reveal_type(fn) # N: Revealed type is "def (*Any, **Any) -> Any"
10791082

1080-
def test_impl(x: Callable[[int], int]) -> None:
1083+
def test_impl(x: FnImpl) -> None:
1084+
match x:
1085+
case Callable() as fn:
1086+
reveal_type(fn) # N: Revealed type is "__main__.FnImpl"
1087+
1088+
def test_callable(x: Callable[[object], int]) -> None:
10811089
match x:
10821090
case Callable() as fn:
1083-
reveal_type(fn) # N: Revealed type is "def (builtins.int) -> builtins.int"
1091+
reveal_type(fn) # N: Revealed type is "def (builtins.object) -> builtins.int"
10841092

10851093

10861094
[case testMatchClassPatternCallbackProtocol]

0 commit comments

Comments
 (0)