PyDocs

Nav

Development Tools

Required

typing

data · Added in 3.11
Special typing construct to mark a TypedDict key as required.

This is mainly useful for total=False TypedDicts.

For example::

    class Movie(TypedDict, total=False):
        title: Required[str]
        year: int

    m = Movie(
        title='The Matrix',  # type checker error if key is omitted
        year=1999,
    )

There is no runtime checking that a required key is actually provided
when instantiating a related TypedDict.
0 Examples
No examples for typing/Required.
See Also
No see-alsos for typing/Required
0 Notes
No notes for Required