Skip to content

Commit

Permalink
Add testcase for get with list default parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Williams committed Jan 7, 2017
1 parent 31e4745 commit 24d2ae6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test-data/unit/check-typeddict.test
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,15 @@ p = PointSet(first_point=TaggedPoint(type='2d', x=42, y=1337))
p.get('first_point', 32).get('x', 0) # E: Some element of union has no attribute "get"
[builtins fixtures/dict.pyi]

[case testGetMethodOnList]
from typing import List
from mypy_extensions import TypedDict
TaggedPoint = TypedDict('TaggedPoint', {'type': str, 'x': int, 'y': int})
PointSet = TypedDict('PointSet', {'points': List[TaggedPoint]})
p = PointSet(points=[TaggedPoint(type='2d', x=42, y=1337)])
reveal_type(p.get('points', [])) # E: Revealed type is 'builtins.list[TypedDict(type=builtins.str, x=builtins.int, y=builtins.int, _fallback=__main__.TaggedPoint)]'
[builtins fixtures/dict.pyi]

[case testDictGetMethodStillCallable]
from typing import Callable
from mypy_extensions import TypedDict
Expand Down

0 comments on commit 24d2ae6

Please sign in to comment.