Skip to content

Commit 764f867

Browse files
committed
Feedback
1 parent 04bccd6 commit 764f867

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

peps/pep-0764.rst

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ any :term:`typing:type qualifier` can be used for individual fields::
115115
Inlined typed dictionaries are implicitly *total*, meaning all keys must be
116116
present. Using the :data:`~typing.Required` type qualifier is thus redundant.
117117

118-
If :pep:`728` gets accepted, inlined typed dictionaries will be implicitly
119-
:ref:`closed <typed-dict-closed>`.
120-
121118
Type variables are allowed in inlined typed dictionaries, provided that they
122119
are bound to some outer scope::
123120

@@ -137,15 +134,12 @@ are bound to some outer scope::
137134

138135
T = TypeVar('T')
139136

140-
InlinedTD = TypedDict[{'name': T}] # Not OK, `T` refers to a type variable that is not bound to any scope.
141-
137+
InlinedTD = TypedDict[{'name': T}] # OK, same as the previous type alias, but using the old-style syntax.
142138

143-
It is not possible for an inlined typed dictionary to be extended::
144139

145-
InlinedTD = TypedDict[{'a': int}]
140+
def func():
141+
InlinedTD = TypedDict[{'name': T}] # Not OK: `T` refers to a type variable that is not bound to the scope of `func`.
146142

147-
class SubTD(InlinedTD): # Not allowed
148-
pass
149143

150144
Typing specification changes
151145
----------------------------
@@ -304,8 +298,8 @@ As inlined typed dictionaries are meant to only support a subset of the
304298
existing syntax, adding this extension mechanism isn't compelling
305299
enough to be supported, considering the added complexity.
306300

307-
If intersections were to be added into the type system, it would most
308-
likely cover this use case.
301+
If intersections were to be added into the type system, it could cover this
302+
use case.
309303

310304

311305
Open Issues
@@ -328,6 +322,23 @@ implementation to provide the introspection attributes (such as
328322
:attr:`~typing.TypedDict.__total__`), and tools relying on runtime
329323
introspection would have to add proper support for this new type.
330324

325+
Depending on the outcome of the runtime implementation, we can more or less
326+
easily allow extending inlined typed dictionaries::
327+
328+
InlinedTD = TypedDict[{'a': int}]
329+
330+
# If `InlinedTD` is a typing._InlinedTypedDict instance, this adds complexity:
331+
class SubTD(InlinedTD):
332+
pass
333+
334+
Inlined typed dictionaries and extra items
335+
------------------------------------------
336+
337+
:pep:`728` introduces the concept of :ref:`closed <typed-dict-closed>` type
338+
dictionaries. If this PEP were to be accepted, inlined typed dictionaries
339+
will be *closed* by default. This means :pep:`728` needs to be addressed
340+
first, so that this PEP can be updated accordingly.
341+
331342

332343
Copyright
333344
=========

0 commit comments

Comments
 (0)