Skip to content

Commit 2857d69

Browse files
committed
Sydney's feedback
1 parent 2e0c379 commit 2857d69

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

peps/pep-0764.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ times, it is used to return or accept structured data in functions. However,
3939
it can get tedious to define :class:`~typing.TypedDict` classes:
4040

4141
* A typed dictionary requires a name, which might not be relevant.
42-
* Nested dictionaries requires more than one class definition.
42+
* Nested dictionaries require more than one class definition.
4343

4444
Taking a simple function returning some nested structured data as an example::
4545

@@ -82,6 +82,9 @@ used), inlined typed dictionaries can be assigned to a variable, as an alias::
8282

8383
InlinedTD = TypedDict[{'name': str}]
8484

85+
def get_movie() -> InlinedTD:
86+
...
87+
8588

8689
Specification
8790
=============
@@ -92,7 +95,7 @@ semantics as the :ref:`functional syntax <typing:typeddict-functional-syntax>`
9295
(the dictionary keys are strings representing the field names, and values are
9396
valid :ref:`annotation expressions <typing:annotation-expression>`).
9497

95-
Inlined typed dictionaries can be referred as being *anonymous*, meaning they
98+
Inlined typed dictionaries can be referred to as *anonymous*, meaning they
9699
don't have a name. For this reason, their :attr:`~type.__name__` attribute
97100
will be set to an empty string.
98101

@@ -125,7 +128,7 @@ are bound to some outer scope::
125128
reveal_type(fn('a')['name']) # Revealed type is 'str'
126129

127130

128-
type InlinedTD[T] = TypedDict[{'name': T}] # OK
131+
type InlinedTD[T] = TypedDict[{'name': T}] # OK, `T` is scoped to the type alias.
129132

130133

131134
T = TypeVar('T')
@@ -154,8 +157,8 @@ Although :class:`~typing.TypedDict` is commonly referred as a class, it is
154157
implemented as a function at runtime. To be made subscriptable, it will be
155158
changed to be a class.
156159

157-
Creating an inlined typed dictionary results in a new class, so both syntaxes
158-
return the same type (apart from the different :attr:`~type.__name__`)::
160+
Creating an inlined typed dictionary results in a new class, so ``T1`` and
161+
``T2`` are the same type (apart from the different :attr:`~type.__name__`)::
159162

160163
from typing import TypedDict
161164

0 commit comments

Comments
 (0)