Skip to content

Commit 11bdb88

Browse files
author
Roy Williams
committed
Add test to ensure get method is still treated as a callable
1 parent e30a603 commit 11bdb88

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test-data/unit/check-typeddict.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,26 @@ p = PointSet(first_point=TaggedPoint(type='2d', x=42, y=1337))
463463
reveal_type(p.get('first_point', {}).get('x')) # E: Revealed type is 'builtins.int'
464464
[builtins fixtures/dict.pyi]
465465

466+
[case testDictGetMethodStillCallable]
467+
from typing import Callable
468+
from mypy_extensions import TypedDict
469+
Point = TypedDict('Point', {'x': int, 'y': int})
470+
p = Point(x=42, y=13)
471+
def invoke_method(method: Callable[[str, int], int]) -> None:
472+
pass
473+
invoke_method(p.get)
474+
[builtins fixtures/dict.pyi]
475+
476+
[case testDictGetMethodStillCallableWithObject]
477+
from typing import Callable
478+
from mypy_extensions import TypedDict
479+
TaggedPoint = TypedDict('TaggedPoint', {'type': str, 'x': int, 'y': int})
480+
p = TaggedPoint(type='2d', x=42, y=1337)
481+
def invoke_method(method: Callable[..., object]) -> None:
482+
pass
483+
invoke_method(p.get)
484+
[builtins fixtures/dict.pyi]
485+
466486
-- TODO: Implement support for these cases:
467487
--[case testGetOfTypedDictWithValidStringLiteralKeyReturnsPreciseType]
468488
--[case testGetOfTypedDictWithInvalidStringLiteralKeyIsError]

0 commit comments

Comments
 (0)