Skip to content

Commit 24d2ae6

Browse files
author
Roy Williams
committed
Add testcase for get with list default parameter
1 parent 31e4745 commit 24d2ae6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test-data/unit/check-typeddict.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,15 @@ p = PointSet(first_point=TaggedPoint(type='2d', x=42, y=1337))
480480
p.get('first_point', 32).get('x', 0) # E: Some element of union has no attribute "get"
481481
[builtins fixtures/dict.pyi]
482482

483+
[case testGetMethodOnList]
484+
from typing import List
485+
from mypy_extensions import TypedDict
486+
TaggedPoint = TypedDict('TaggedPoint', {'type': str, 'x': int, 'y': int})
487+
PointSet = TypedDict('PointSet', {'points': List[TaggedPoint]})
488+
p = PointSet(points=[TaggedPoint(type='2d', x=42, y=1337)])
489+
reveal_type(p.get('points', [])) # E: Revealed type is 'builtins.list[TypedDict(type=builtins.str, x=builtins.int, y=builtins.int, _fallback=__main__.TaggedPoint)]'
490+
[builtins fixtures/dict.pyi]
491+
483492
[case testDictGetMethodStillCallable]
484493
from typing import Callable
485494
from mypy_extensions import TypedDict

0 commit comments

Comments
 (0)