class documentation

class TypedDictType(ProperType): (source)

View In Hierarchy

Type of TypedDict object {'k1': v1, ..., 'kn': vn}.

A TypedDict object is a dictionary with specific string (literal) keys. Each key has a value with a distinct type that depends on the key. TypedDict objects are normal dict objects at runtime.

A TypedDictType can be either named or anonymous. If it's anonymous, its fallback will be typing_extensions._TypedDict (Instance). _TypedDict is a subclass of Mapping[str, object] and defines all non-mapping dict methods that TypedDict supports. Some dict methods are unsafe and not supported. _TypedDict isn't defined at runtime.

If a TypedDict is named, its fallback will be an Instance of the named type (ex: "Point") whose TypeInfo has a typeddict_type that is anonymous. This is similar to how named tuples work.

TODO: The fallback structure is perhaps overly complicated.

Class Method deserialize Undocumented
Method __eq__ Undocumented
Method __hash__ Undocumented
Method __init__ Undocumented
Method accept Undocumented
Method as​_anonymous Undocumented
Method copy​_modified Undocumented
Method create​_anonymous​_fallback Undocumented
Method is​_anonymous Undocumented
Method names​_are​_wider​_than Undocumented
Method serialize Undocumented
Method zip Undocumented
Method zipall Undocumented
Class Variable __slots__ Undocumented
Instance Variable can​_be​_false Undocumented
Instance Variable can​_be​_true Undocumented
Instance Variable fallback Undocumented
Instance Variable items Undocumented
Instance Variable required​_keys Undocumented

Inherited from Type (via ProperType):

Method __repr__ Undocumented
Method can​_be​_false​_default Undocumented
Method can​_be​_true​_default Undocumented

Inherited from Context (via ProperType, Type):

Method get​_column Don't use. Use x.column.
Method get​_line Don't use. Use x.line.
Method set​_line If target is a node, pull line (and column) information into this node. If column is specified, this will override any column information coming from a node.
Instance Variable column Undocumented
Instance Variable end​_line Undocumented
Instance Variable line Undocumented
@classmethod
def deserialize(cls, data): (source)

Undocumented

Parameters
data:JsonDictUndocumented
Returns
TypedDictTypeUndocumented
def __eq__(self, other): (source)

Undocumented

Parameters
other:objectUndocumented
Returns
boolUndocumented
def __hash__(self): (source)

Undocumented

Returns
intUndocumented
def __init__(self, items, required_keys, fallback, line=-1, column=-1): (source)

Undocumented

Parameters
items:OrderedDict[str, Type]Undocumented
required​_keys:Set[str]Undocumented
fallback:InstanceUndocumented
line:intUndocumented
column:intUndocumented
def accept(self, visitor): (source)

Undocumented

Parameters
visitor:TypeVisitor[T]Undocumented
Returns
TUndocumented
def as_anonymous(self): (source)

Undocumented

Returns
TypedDictTypeUndocumented
def copy_modified(self, *, fallback=None, item_types=None, required_keys=None): (source)

Undocumented

Parameters
fallback:Optional[Instance]Undocumented
item​_types:Optional[List[Type]]Undocumented
required​_keys:Optional[Set[str]]Undocumented
Returns
TypedDictTypeUndocumented
def create_anonymous_fallback(self, *, value_type): (source)

Undocumented

Parameters
value​_type:TypeUndocumented
Returns
InstanceUndocumented
def is_anonymous(self): (source)

Undocumented

Returns
boolUndocumented
def names_are_wider_than(self, other): (source)

Undocumented

Parameters
other:TypedDictTypeUndocumented
Returns
boolUndocumented
def serialize(self): (source)

Undocumented

Returns
JsonDictUndocumented
def zip(self, right): (source)

Undocumented

Parameters
right:TypedDictTypeUndocumented
Returns
Iterable[Tuple[str, Type, Type]]Undocumented
def zipall(self, right): (source)

Undocumented

Parameters
right:TypedDictTypeUndocumented
Returns
Iterable[Tuple[str, Optional[Type], Optional[Type]]]Undocumented
__slots__: tuple[str, ...] = (source)

Undocumented

can_be_false = (source)

Undocumented

can_be_true = (source)

Undocumented

fallback = (source)

Undocumented

items = (source)

Undocumented

required_keys = (source)

Undocumented