It looks like there’s an error in one of the examples under “The extra_items Class Parameter”:
class MovieBase(TypedDict, extra_items=int | None):
name: str
class Movie(MovieBase):
year: int
a: Movie = {"name": "Blade Runner", "year": None} # Not OK. 'None' is incompatible with 'int'
b: Movie = {
"name": "Blade Runner",
"year": 1982,
"other_extra_key": None,
} # OK
I think MoviedBase should be defined like this, using ReadOnly, based on the discussion in section “Inheritance”, for Movie to be valid:
class MovieBase(TypedDict, extra_items=ReadOnly[int | None]):
name: str