@@ -1048,17 +1048,33 @@ typing
10481048
10491049The:mod: `typing ` module incorporates several new features:
10501050
1051- * Protocol definitions. See:pep: `544 `,:class: `typing.Protocol ` and
1052- :func: `typing.runtime_checkable `. Simple ABCs like
1053- :class: `typing.SupportsInt ` are now ``Protocol `` subclasses.
1054-
10551051* A dictionary type with per-key types. See:pep: `589 ` and
10561052:class: `typing.TypedDict `.
1053+ TypedDict uses only string keys. By default, every key is required
1054+ to be present. Specify "total=False" to allow keys to be optional::
1055+
1056+ class Location(TypedDict, total=False):
1057+ lat_long: tuple
1058+ grid_square: str
1059+ xy_coordinate: tuple
10571060
10581061* Literal types. See:pep: `586 ` and:class: `typing.Literal `.
1062+ Literal types indicate that a parameter or return value
1063+ is constrained to one or more specific literal values::
1064+
1065+ def get_status(port: int) -> Literal['connected', 'disconnected']:
1066+ ...
10591067
10601068* "Final" variables, functions, methods and classes. See:pep: `591 `,
10611069:class: `typing.Final ` and:func: `typing.final `.
1070+ The final qualifier instructs a static type checker to restrict
1071+ subclassing, overriding, or reassignment::
1072+
1073+ pi: Final[float] = 3.1415926536
1074+
1075+ * Protocol definitions. See:pep: `544 `,:class: `typing.Protocol ` and
1076+ :func: `typing.runtime_checkable `. Simple ABCs like
1077+ :class: `typing.SupportsInt ` are now ``Protocol `` subclasses.
10621078
10631079* New protocol class:class: `typing.SupportsIndex `.
10641080
@@ -1527,7 +1543,7 @@ Changes in Python behavior
15271543 terminate the current thread if called while the interpreter is
15281544 finalizing, making them consistent with:c:func: `PyEval_RestoreThread `,
15291545:c:func: `Py_END_ALLOW_THREADS `, and:c:func: `PyGILState_Ensure `. If this
1530- behaviour is not desired, guard the call by checking:c:func: `_Py_IsFinalizing `
1546+ behavior is not desired, guard the call by checking:c:func: `_Py_IsFinalizing `
15311547 or:c:func: `sys.is_finalizing `.
15321548
15331549Changes in the Python API