diff --git a/peps/pep-0764.rst b/peps/pep-0764.rst index 324745b438e5..21182eff2cfc 100644 --- a/peps/pep-0764.rst +++ b/peps/pep-0764.rst @@ -100,11 +100,11 @@ It is possible to define a nested inlined dictionary:: Movie = TypedDict[{'name': str, 'production': TypedDict[{'location': str}]}] - # Note that the following is invalid as per the updated `type_expression` production: + # Note that the following is invalid as per the updated `type_expression` grammar: Movie = TypedDict[{'name': str, 'production': {'location': str}}] Although it is not possible to specify any class arguments such as ``total``, -Any :external+typing:term:`type qualifier` can be used for individual fields:: +any :external+typing:term:`type qualifier` can be used for individual fields:: Movie = TypedDict[{'name': NotRequired[str], 'year': ReadOnly[int]}] @@ -134,6 +134,19 @@ are bound to some outer scope:: **TODO** closed +Typing specification changes +---------------------------- + +The inlined typed dictionary adds a new kind of +:term:`type expressions `. As such, the +:external+typing:token:`~expression-grammar:type_expression` production will +need to be updated to include the inlined syntax: + +.. productionlist:: inlined-typed-dictionaries-grammar + new-type_expression: `~expression-grammar:type_expression` + : | '[' '{' (string: ':' `~expression-grammar:annotation_expression` ',')* '}' ']' + (where string is any string literal) + Runtime behavior ---------------- @@ -149,19 +162,6 @@ return the same type (apart from the different :attr:`~type.__name__`):: T1 = TypedDict('T1', {'a': int}) T2 = TypedDict[{'a': int}] -Typing specification changes ----------------------------- - -The inlined typed dictionary adds a new kind of -:term:`type expressions `. As such, the -:external+typing:token:`~expression-grammar:type_expression` production will -need to be updated to include the inlined syntax: - -.. productionlist:: inlined-typed-dictionaries-grammar - new-type_expression: `~expression-grammar:type_expression` - : | '[' '{' (string: ':' `~expression-grammar:annotation_expression` ',')* '}' ']' - (where string is any string literal) - Backwards Compatibility =======================