|
13 | 13 | * Public helper functions: get_type_hints, overload, cast, no_type_check, |
14 | 14 | no_type_check_decorator. |
15 | 15 | * Generic aliases for collections.abc ABCs and few additional protocols. |
16 | | -* Special types: NewType, NamedTuple, TypedDict (may be added soon). |
| 16 | +* Special types: NewType, NamedTuple, TypedDict. |
17 | 17 | * Wrapper submodules for re and io related types. |
18 | 18 | """ |
19 | 19 |
|
@@ -1885,6 +1885,19 @@ class Point2D(TypedDict): |
1885 | 1885 | Point2D = TypedDict('Point2D', x=int, y=int, label=str) |
1886 | 1886 | Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str}) |
1887 | 1887 |
|
| 1888 | + By default, all keys must be present in a TypedDict. It is possible |
| 1889 | + to override this by specifying totality. |
| 1890 | + Usage:: |
| 1891 | +
|
| 1892 | + class point2D(TypedDict, total=False): |
| 1893 | + x: int |
| 1894 | + y: int |
| 1895 | +
|
| 1896 | + This means that a point2D TypedDict can have any of the keys omitted.A type |
| 1897 | + checker is only expected to support a literal False or True as the value of |
| 1898 | + the total argument. True is the default, and makes all items defined in the |
| 1899 | + class body be required. |
| 1900 | +
|
1888 | 1901 | The class syntax is only supported in Python 3.6+, while two other |
1889 | 1902 | syntax forms work for Python 2.7 and 3.2+ |
1890 | 1903 | """ |
|
0 commit comments