| 1 |
-- Create Type |
| 2 |
|
| 3 |
-- TODO: Implement support for this syntax. |
| 4 |
--[case testCanCreateTypedDictTypeWithDictCall] |
| 5 |
--from typing import TypedDict |
| 6 |
--Point = TypedDict('Point', dict(x=int, y=int)) |
| 7 |
--[builtins fixtures/dict.pyi] |
| 8 |
--[typing fixtures/typing-typeddict.pyi] |
| 9 |
--[out] |
| 10 |
--MypyFile:1( |
| 11 |
-- ImportFrom:1(typing, [TypedDict]) |
| 12 |
-- AssignmentStmt:2( |
| 13 |
-- NameExpr(Point* [__main__.Point]) |
| 14 |
-- TypedDictExpr:2(Point))) |
| 15 |
|
| 16 |
[case testCanCreateTypedDictTypeWithDictLiteral] |
| 17 |
from typing import TypedDict |
| 18 |
Point = TypedDict('Point', {'x': int, 'y': int}) |
| 19 |
[builtins fixtures/dict.pyi] |
| 20 |
[typing fixtures/typing-typeddict.pyi] |
| 21 |
[out] |
| 22 |
MypyFile:1( |
| 23 |
ImportFrom:1(typing, [TypedDict]) |
| 24 |
AssignmentStmt:2( |
| 25 |
NameExpr(Point* [__main__.Point]) |
| 26 |
TypedDictExpr:2(Point))) |
| 27 |
|
| 28 |
[case testTypedDictWithDocString] |
| 29 |
from typing import TypedDict |
| 30 |
class A(TypedDict): |
| 31 |
"""foo""" |
| 32 |
x: str |
| 33 |
[builtins fixtures/dict.pyi] |
| 34 |
[typing fixtures/typing-typeddict.pyi] |
| 35 |
[out] |
| 36 |
MypyFile:1( |
| 37 |
ImportFrom:1(typing, [TypedDict]) |
| 38 |
ClassDef:2( |
| 39 |
A |
| 40 |
BaseType( |
| 41 |
typing._TypedDict) |
| 42 |
ExpressionStmt:3( |
| 43 |
StrExpr(foo)) |
| 44 |
AssignmentStmt:4( |
| 45 |
NameExpr(x) |
| 46 |
TempNode:4( |
| 47 |
Any) |
| 48 |
builtins.str))) |