From 32392a9ca377c7a2b6ef98941ec2584d2440ace0 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Sun, 29 Jun 2025 18:35:03 -0400 Subject: [PATCH] PEP 728: Fix minor issues with examples Jukka pointed out the incorrect use of extra_items here: https://discuss.python.org/t/pep-728-typeddict-with-typed-extra-items/45443/157 Also fixed a minor issue with a class missing its body. --- peps/pep-0728.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/peps/pep-0728.rst b/peps/pep-0728.rst index 6b370d5018e..6785e937e62 100644 --- a/peps/pep-0728.rst +++ b/peps/pep-0728.rst @@ -215,7 +215,7 @@ the ``extra_items`` argument:: ``extra_items`` is inherited through subclassing:: - class MovieBase(TypedDict, extra_items=int | None): + class MovieBase(TypedDict, extra_items=ReadOnly[int | None]): name: str class Movie(MovieBase): @@ -380,6 +380,7 @@ unless it is declared to be ``ReadOnly`` in the superclass:: pass class Child(Parent, extra_items=int): # Not OK. Like any other TypedDict item, extra_items's type cannot be changed + pass Second, ``extra_items=T`` effectively defines the value type of any unnamed items accepted to the TypedDict and marks them as non-required. Thus, the above