Skip to content

Commit 77ae2d1

Browse files
committed
Carl feedback
1 parent 0f18c4b commit 77ae2d1

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

docs/spec/concepts.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ attributes and/or methods.
6969

7070
If an object ``v`` is a member of the set of objects denoted by a fully static
7171
type ``T``, we can say that ``v`` is a "member of" the type ``T``, or ``v``
72-
"inhabits" ``T``.
72+
":term:`inhabits <inhabit>`" ``T``.
7373

7474
Gradual types
7575
~~~~~~~~~~~~~
@@ -298,9 +298,9 @@ visualize this analogy in the following table:
298298
* - ``B`` is :term:`equivalent` to ``A``
299299
- ``B`` is :term:`consistent` with ``A``
300300

301-
We can also define an **equivalence** relation on gradual types: the gradual
302-
types ``A`` and ``B`` are equivalent (that is, the same gradual type, not
303-
merely consistent with one another) if and only if all materializations of
301+
We can also define an **equivalence** relation on gradual types: the gradual
302+
types ``A`` and ``B`` are equivalent (that is, the same gradual type, not
303+
merely consistent with one another) if and only if all materializations of
304304
``A`` are also materializations of ``B``, and all materializations of ``B``
305305
are also materializations of ``A``.
306306

docs/spec/glossary.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ This section defines a few terms that may be used elsewhere in the specification
6161

6262
extra items
6363
A :ref:`TypedDict <typeddict>` type with extra items may contain arbitrary
64-
additional :term:`items <item>` beyond those specified in the TypedDict definition, but those
65-
items must be of the type specified by that definition.
64+
additional key-value pairs beyond those specified in the TypedDict definition, but those
65+
values must be of the type specified by the ``extra_items=`` argument to the definition.
6666
A TypedDict with extra items can be created using the ``extra_items=``
6767
argument to :py:func:`typing.TypedDict`. Extra items may or may not be
6868
:term:`read-only`. Compare :term:`closed` and :term:`open`.
@@ -94,6 +94,11 @@ This section defines a few terms that may be used elsewhere in the specification
9494
They can be :term:`materialized <materialize>` to a more static, or fully static,
9595
type. See :ref:`type-system-concepts`.
9696

97+
inhabit
98+
A value is said to inhabit a type if it is a member of the set of values
99+
represented by that type. For example, the value ``42`` inhabits the type
100+
``int``, and the value ``"hello"`` inhabits the type ``str``.
101+
97102
inline
98103
Inline type annotations are annotations that are included in the
99104
runtime code using :pep:`526` and

docs/spec/typeddict.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and ``NotRequired`` in :pep:`655`, use with ``Unpack`` in :pep:`692`,
1010

1111
A TypedDict type represents ``dict`` objects that contain only keys of
1212
type ``str``. There are restrictions on which string keys are valid, and
13-
which values can be associated with each key. Values that are members of a
13+
which values can be associated with each key. Values that :term:`inhabit` a
1414
TypedDict type must be instances of ``dict`` itself, not a subclass.
1515

1616
TypedDict types can define any number of :term:`items <item>`, which are string
@@ -371,10 +371,12 @@ Example::
371371
class X(TypedDict):
372372
x: str
373373
y: ReadOnly[int]
374+
z: int
374375

375376
class Y(X):
376377
x: int # Type check error: cannot overwrite TypedDict field "x"
377378
y: bool # OK: bool is assignable to int, and a mutable item can override a read-only one
379+
z: bool # Type check error: key is mutable, so subclass type must be consistent with superclass
378380

379381
Openness
380382
^^^^^^^^

0 commit comments

Comments
 (0)