TypeTypedDict

Auto-generated documentation for mypy_boto3_builder.type_annotations.type_typed_dict module.

Wrapper for typing/typing_extensions.TypedDict type annotations.

TypeTypedDict

[find in source code]

class TypeTypedDict(FakeAnnotation):
    def __init__(
        name: str,
        children: Iterable[TypedDictAttribute] = (),
        docstring: str = '',
        stringify: bool = False,
        replace_with_dict: bool = False,
    ) -> None:

Wrapper for typing/typing_extensions.TypedDict type annotations.

Arguments

  • name - Type name.
  • children - Typed dict attributes.
  • docstring - Docstring for render.
  • stringify - Convert type annotation to string to avoid circular deps.
  • replace_with_dict - Render Dict[str, Any] instead to avoid circular dependencies.

See also

TypeTypedDict().add_attribute

[find in source code]

def add_attribute(
    name: str,
    type_annotation: FakeAnnotation,
    required: bool,
) -> None:

Add new attribute to a dictionary.

Arguments

  • name - Argument name.
  • type_annotation - Argument type annotation.
  • required - Whether argument has to be set.

See also

TypeTypedDict().copy

[find in source code]

def copy() -> 'TypeTypedDict':

Create a copy of type annotation wrapper.

TypeTypedDict().get_attribute

[find in source code]

def get_attribute(name: str) -> TypedDictAttribute:

See also

TypeTypedDict().get_children_typed_dicts

[find in source code]

def get_children_typed_dicts() -> Set['TypeTypedDict']:

TypeTypedDict().get_children_types

[find in source code]

def get_children_types() -> Set[FakeAnnotation]:

TypeTypedDict().get_import_record

[find in source code]

def get_import_record() -> ImportRecord:

Get import record required for using type annotation.

See also

TypeTypedDict().get_optional

[find in source code]

def get_optional() -> List[TypedDictAttribute]:

TypeTypedDict().get_required

[find in source code]

def get_required() -> List[TypedDictAttribute]:

TypeTypedDict().get_types

[find in source code]

def get_types() -> Set[FakeAnnotation]:

Get set with itself.

To get child types, TypeTypedDict().get_children_types has to be used.

Returns

A set of type annotations.

TypeTypedDict().has_both

[find in source code]

def has_both() -> bool:

Whether TypedDict has both optional and required keys.

TypeTypedDict().has_optional

[find in source code]

def has_optional() -> bool:

Whether TypedDict has optional keys.

TypeTypedDict().has_required

[find in source code]

def has_required() -> bool:

Whether TypedDict has required keys.

TypeTypedDict().is_dict

[find in source code]

def is_dict() -> bool:

Always True as it is a TypedDict.

TypeTypedDict().is_same

[find in source code]

def is_same(other: 'TypeTypedDict') -> bool:

TypeTypedDict().render

[find in source code]

def render(parent_name: str = '') -> str:

Render type annotation to a valid Python code for local usage.

Returns

A string with a valid type annotation.

TypeTypedDict().render_class

[find in source code]

def render_class() -> str:

Render class-based definition for debugging.

TypeTypedDict().replace_self_references

[find in source code]

def replace_self_references() -> List[str]:

Replace self refenrences with Dict[str, Any] to avoid circular dependencies.

Returns

A list of replaced children names.

TypedDictAttribute

[find in source code]

class TypedDictAttribute():
    def __init__(name: str, type_annotation: FakeAnnotation, required: bool):

TypedDict attribute wrapper.

Arguments

  • name - Attribute name.
  • type_annotation - Attribute type annotation.
  • required - Whether the attribute has to be set.

See also

TypedDictAttribute().render

[find in source code]

def render() -> str:

Render attribute to use in class-based TypedDict definition.

Returns

A string with argument definition.