TypeTypedDict
Auto-generated documentation for builder.mypy_boto3_builder.type_annotations.type_typed_dict module.
Wrapper for typing/typing_extensions.TypedDict
type annotations.
- mypy-boto3 / Modules /
Builder
/ Mypy Boto3 Builder / Type Annotations / TypeTypedDict- TypeTypedDict
- TypeTypedDict().add_attribute
- TypeTypedDict().copy
- TypeTypedDict().get_attribute
- TypeTypedDict().get_children_types
- TypeTypedDict().get_import_record
- TypeTypedDict().get_optional
- TypeTypedDict().get_required
- TypeTypedDict().get_types
- TypeTypedDict().has_both
- TypeTypedDict().has_optional
- TypeTypedDict().has_required
- TypeTypedDict().is_dict
- TypeTypedDict().is_same
- TypeTypedDict().render
- TypeTypedDict().render_class
- TypedDictAttribute
- TypeTypedDict
TypeTypedDict
class TypeTypedDict(FakeAnnotation):
def __init__(
name: str,
children: Iterable[TypedDictAttribute] = (),
docstring: str = '',
) -> None:
Wrapper for typing/typing_extensions.TypedDict
type annotations.
Arguments
name
- Type name.children
- Typed dict attributes.docstring
- Docstring for render.
TypeTypedDict().add_attribute
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.
TypeTypedDict().copy
def copy() -> 'TypeTypedDict':
Create a copy of type annotation wrapper.
TypeTypedDict().get_attribute
def get_attribute(name: str) -> TypedDictAttribute:
See also
TypeTypedDict().get_children_types
def get_children_types() -> Set[FakeAnnotation]:
TypeTypedDict().get_import_record
def get_import_record() -> ImportRecord:
Get import record required for using type annotation.
TypeTypedDict().get_optional
def get_optional() -> List[TypedDictAttribute]:
TypeTypedDict().get_required
def get_required() -> List[TypedDictAttribute]:
TypeTypedDict().get_types
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
def has_both() -> bool:
Whether TypedDict has both optional and required keys.
TypeTypedDict().has_optional
def has_optional() -> bool:
Whether TypedDict has optional keys.
TypeTypedDict().has_required
def has_required() -> bool:
Whether TypedDict has required keys.
TypeTypedDict().is_dict
def is_dict() -> bool:
Always True as it is a TypedDict.
TypeTypedDict().is_same
def is_same(other: 'TypeTypedDict') -> bool:
TypeTypedDict().render
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
def render_class() -> str:
Render class-based definition for debugging.
TypedDictAttribute
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.
TypedDictAttribute().render
def render() -> str:
Render attribute to use in class-based TypedDict definition.
Returns
A string with argument definition.