We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc725ba commit 9bb31f4Copy full SHA for 9bb31f4
mypy_extensions.py
@@ -7,4 +7,16 @@
7
8
# NOTE: This module must support Python 2.7 in addition to Python 3.x
9
10
-# (TODO: Declare TypedDict and other extensions here)
+
11
+def TypedDict(typename, fields):
12
+ """TypedDict creates a dictionary type that expects all of its
13
+ instances to have a certain set of keys, with each key
14
+ associated with a value of a consistent type. This expectation
15
+ is not checked at runtime but is only enforced by typecheckers.
16
+ """
17
+ def new_dict(*args, **kwargs):
18
+ return dict(*args, **kwargs)
19
20
+ new_dict.__name__ = typename
21
+ new_dict.__supertype__ = dict
22
+ return new_dict
0 commit comments