TypeTypedDict

mypy-boto3-builder Index / Mypy Boto3 Builder / Type Annotations / TypeTypedDict

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

TypeTypedDict

Show source in type_typed_dict.py:63

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.

Signature

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

See also

TypeTypedDict().add_attribute

Show source in type_typed_dict.py:166

Add new attribute to a dictionary.

Arguments

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

Signature

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

See also

TypeTypedDict().copy

Show source in type_typed_dict.py:233

Create a copy of type annotation wrapper.

Signature

def copy(self) -> "TypeTypedDict":
    ...

TypeTypedDict().get_attribute

Show source in type_typed_dict.py:112

Find attribute by name.

Arguments

  • name - Attribute name.

Returns

Found attribute.

Signature

def get_attribute(self, name: str) -> TypedDictAttribute:
    ...

See also

TypeTypedDict().get_children_literals

Show source in type_typed_dict.py:275

Extract required TypeLiteral list from attributes.

Signature

def get_children_literals(
    self, processed: Iterable["TypeTypedDict"] = tuple()
) -> set[TypeLiteral]:
    ...

See also

TypeTypedDict().get_children_typed_dicts

Show source in type_typed_dict.py:262

Extract required TypeTypedDict list from attributes.

Signature

def get_children_typed_dicts(self) -> set["TypeTypedDict"]:
    ...

TypeTypedDict().get_children_types

Show source in type_typed_dict.py:253

Extract required type annotations from attributes.

Signature

def get_children_types(self) -> set[FakeAnnotation]:
    ...

See also

TypeTypedDict().get_import_record

Show source in type_typed_dict.py:160

Get import record required for using type annotation.

Signature

def get_import_record(self) -> ImportRecord:
    ...

See also

TypeTypedDict().get_local_types

Show source in type_typed_dict.py:324

Get internal types generated by builder.

Signature

def get_local_types(self) -> list[FakeAnnotation]:
    ...

See also

TypeTypedDict().get_optional

Show source in type_typed_dict.py:223

Get a list of optional attributes.

Signature

def get_optional(self) -> list[TypedDictAttribute]:
    ...

See also

TypeTypedDict().get_required

Show source in type_typed_dict.py:213

Get a list of required attributes.

Signature

def get_required(self) -> list[TypedDictAttribute]:
    ...

See also

TypeTypedDict().get_sort_key

Show source in type_typed_dict.py:101

Sort Typed Dicts by name.

Signature

def get_sort_key(self) -> str:
    ...

TypeTypedDict.get_typing_import_record

Show source in type_typed_dict.py:146

Get import record required for using TypedDict.

Fallback to typing_extensions for py38-.

Signature

@staticmethod
def get_typing_import_record() -> ImportRecord:
    ...

See also

TypeTypedDict().has_both

Show source in type_typed_dict.py:207

Whether TypedDict has both optional and required keys.

Signature

def has_both(self) -> bool:
    ...

TypeTypedDict().has_optional

Show source in type_typed_dict.py:189

Whether TypedDict has optional keys.

Signature

def has_optional(self) -> bool:
    ...

TypeTypedDict().has_required

Show source in type_typed_dict.py:198

Whether TypedDict has required keys.

Signature

def has_required(self) -> bool:
    ...

TypeTypedDict().is_dict

Show source in type_typed_dict.py:177

Always True as it is a TypedDict.

Signature

def is_dict(self) -> bool:
    ...

TypeTypedDict().is_same

Show source in type_typed_dict.py:245

Check whether typed dict attributes are the same as other.

Signature

def is_same(self, other: "TypeTypedDict") -> bool:
    ...

TypeTypedDict().is_stringified

Show source in type_typed_dict.py:89

Whether TypedDict usage should be rendered as a string.

Signature

def is_stringified(self) -> bool:
    ...

TypeTypedDict().is_typed_dict

Show source in type_typed_dict.py:183

Always True as it is a TypedDict.

Signature

def is_typed_dict(self) -> bool:
    ...

TypeTypedDict().iterate_children

Show source in type_typed_dict.py:315

Iterate over children from required to optional.

Signature

def iterate_children(self) -> Iterator[TypedDictAttribute]:
    ...

See also

TypeTypedDict().render

Show source in type_typed_dict.py:128

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

Returns

A string with a valid type annotation.

Signature

def render(self, parent_name: str = "") -> str:
    ...

TypeTypedDict().replace_self_references

Show source in type_typed_dict.py:292

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

Signature

def replace_self_references(self) -> None:
    ...

TypeTypedDict().requires_safe_render

Show source in type_typed_dict.py:307

Whether TypedDict has reserved words and has to be rendered safely.

Signature

@property
def requires_safe_render(self) -> bool:
    ...

TypeTypedDict().stringify

Show source in type_typed_dict.py:95

Render TypedDict usage as a string.

Signature

def stringify(self) -> None:
    ...

TypeTypedDict().type_hint_annotations

Show source in type_typed_dict.py:330

Type annotations list from arguments and return type with internal types.

Signature

@property
def type_hint_annotations(self) -> list[FakeAnnotation]:
    ...

See also

TypedDictAttribute

Show source in type_typed_dict.py:16

TypedDict attribute wrapper.

Arguments

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

Signature

class TypedDictAttribute:
    def __init__(
        self, name: str, type_annotation: FakeAnnotation, required: bool
    ) -> None:
        ...

See also

TypedDictAttribute().get_type_annotation

Show source in type_typed_dict.py:31

Get wrapped for non-required type annotation or raw type annotation.

Signature

def get_type_annotation(self) -> FakeAnnotation:
    ...

See also

TypedDictAttribute().is_required

Show source in type_typed_dict.py:56

Whether argument is required.

Signature

def is_required(self) -> bool:
    ...

TypedDictAttribute().iterate_types

Show source in type_typed_dict.py:49

Itera over type annotations.

Signature

def iterate_types(self) -> Iterator[FakeAnnotation]:
    ...

See also

TypedDictAttribute().render

Show source in type_typed_dict.py:40

Render attribute to use in class-based TypedDict definition.

Returns

A string with argument definition.

Signature

def render(self, parent_name: str = "") -> str:
    ...