You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The *extra_items* argument is also inherited through subclassing. It is unset
2824
+
by default, and it may not be used together with the *closed* argument.
2825
+
2795
2826
A ``TypedDict`` cannot inherit from a non-\ ``TypedDict`` class,
2796
2827
except for :class:`Generic`. For example::
2797
2828
@@ -2825,8 +2856,8 @@ types.
2825
2856
group: list[T]
2826
2857
2827
2858
A ``TypedDict`` can be introspected via annotations dicts
2828
-
(see :ref:`annotations-howto` for more information on annotations best practices),
2829
-
:attr:`__total__`, :attr:`__required_keys__`, and :attr:`__optional_keys__`.
2859
+
(see :ref:`annotations-howto` for more information on annotations best practices)
2860
+
and the following attributes:
2830
2861
2831
2862
.. attribute:: __total__
2832
2863
@@ -2896,8 +2927,6 @@ types.
2896
2927
``__required_keys__`` and ``__optional_keys__`` rely on may not work
2897
2928
properly, and the values of the attributes may be incorrect.
2898
2929
2899
-
Support for :data:`ReadOnly` is reflected in the following attributes:
2900
-
2901
2930
.. attribute:: __readonly_keys__
2902
2931
2903
2932
A :class:`frozenset` containing the names of all read-only keys. Keys
@@ -2912,6 +2941,14 @@ types.
2912
2941
2913
2942
.. versionadded:: 3.13
2914
2943
2944
+
.. attribute:: __closed__
2945
+
2946
+
The value of the *closed* class argument. It can be ``True``, ``False``, or :data:`None`.
2947
+
2948
+
.. attribute:: __extra_items__
2949
+
2950
+
The value of the *extra_items* class argument. It can be a valid type or :data:`NoExtraItems`.
2951
+
2915
2952
See the `TypedDict <https://typing.python.org/en/latest/spec/typeddict.html#typeddict>`_ section in the typing documentation for more examples and detailed rules.
2916
2953
2917
2954
.. versionadded:: 3.8
@@ -2931,7 +2968,10 @@ types.
2931
2968
Removed support for the keyword-argument method of creating ``TypedDict``\ s.
2932
2969
2933
2970
.. versionchanged:: 3.13
2934
-
Support for the :data:`ReadOnly` qualifier was added.
2971
+
Support for the :data:`ReadOnly` qualifier was added. See :pep:`705`.
2972
+
2973
+
.. versionchanged:: next
2974
+
Support for the *closed* and *extra_items* class arguments was added. See :pep:`728`.
2935
2975
2936
2976
2937
2977
Protocols
@@ -3679,6 +3719,21 @@ Introspection helpers
3679
3719
3680
3720
.. versionadded:: 3.13
3681
3721
3722
+
.. data:: NoExtraItems
3723
+
3724
+
A :class:`sentinel` object used to indicate that a :class:`TypedDict`
0 commit comments