ID EN
Typing

is_typeddict

Python 3.11

Check if a type is a TypedDict.

Syntax

PYTHON
typing.is_typeddict(tp)

Examples

Example 1
PYTHON
class Film(TypedDict):
    title: str
    year: int

assert is_typeddict(Film)
assert not is_typeddict(list | str)

 TypedDict is a factory for creating typed dicts,
 not a typed dict itself
assert not is_typeddict(TypedDict)

See Also

TypedDict