typed_dict API documentation

# typed_dict

View Source

     1from typing import Optional
     2from typing import TypedDict
     3
     4
     5class Foo(TypedDict):
     6    a: Optional[int]
     7    """First attribute."""
     8
     9
    10class Bar(Foo, total=False):
    11    """A TypedDict subclass. Before 3.12, TypedDict botches __mro__."""
    12
    13    b: int
    14    """Second attribute."""
    15    c: str
    16    # undocumented attribute
    17
    18
    19class Baz(Bar):
    20    """A TypedDict subsubclass."""
    21
    22    d: bool
    23    """new attribute"""

class Foo(typing.TypedDict): View Source

    6class Foo(TypedDict):
    7    a: Optional[int]
    8    """First attribute."""

a: Optional[int]

First attribute.

class Bar(Foo): View Source

    11class Bar(Foo, total=False):
    12    """A TypedDict subclass. Before 3.12, TypedDict botches __mro__."""
    13
    14    b: int
    15    """Second attribute."""
    16    c: str
    17    # undocumented attribute

A TypedDict subclass. Before 3.12, TypedDict botches __mro__.

b: int

Second attribute.

c: str

##### Inherited Members

Foo
  a

class Baz(Bar): View Source

    20class Baz(Bar):
    21    """A TypedDict subsubclass."""
    22
    23    d: bool
    24    """new attribute"""

A TypedDict subsubclass.

d: bool

new attribute

##### Inherited Members

Bar
  b
  c
Foo
  a