Skip to content

Commit 03756d1

Browse files
committed
add TypedDict
1 parent 4817b2f commit 03756d1

File tree

3 files changed

+134
-70
lines changed

3 files changed

+134
-70
lines changed

Pipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ schematics = "*"
2727
pydantic = "*"
2828
redis = "*"
2929
pendulum = "*"
30+
mypy = "*"
31+
mypy-extensions = "*"
3032

3133

3234
[dev-packages]

Pipfile.lock

Lines changed: 110 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mypy_sp/typed_dict.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from mypy_extensions import TypedDict
2+
3+
4+
class MovieA(TypedDict):
5+
name: str
6+
year: int
7+
8+
9+
MovieB = TypedDict('Movie', {'name': str, 'year': int})
10+
11+
12+
def main():
13+
m1 = MovieA(name='foo', year=2028)
14+
m2 = MovieB(name='bar', year=2029)
15+
print(m1)
16+
print(m2)
17+
print(type(m1))
18+
print(type(m2))
19+
20+
21+
if __name__ == '__main__':
22+
main()

0 commit comments

Comments
 (0)