TypeLiteral
Auto-generated documentation for mypy_boto3_builder.type_annotations.type_literal module.
Wrapper for typing/typing_extensions.Literal
type annotations like Literal['a', 'b']
.
- mypy-boto3-builder / Modules / Mypy Boto3 Builder / Type Annotations / TypeLiteral
TypeLiteral
class TypeLiteral(FakeAnnotation):
def __init__(name: str, children: Iterable[str]) -> None:
Wrapper for typing/typing_extensions.Literal
type annotations like Literal['a', 'b']
.
Arguments
name
- Literal name for non-inline.children
- Literal values.inline
- Render literal inline.
See also
TypeLiteral().add_child
def add_child(child: FakeAnnotation) -> None:
Disabled method to avoid confusion.
See also
TypeLiteral().copy
def copy() -> 'TypeLiteral':
Create a copy of type annotation wrapper.
TypeLiteral().get_import_record
def get_import_record() -> ImportRecord:
Get import record required for using type annotation.
See also
TypeLiteral().get_local_types
def get_local_types() -> list[FakeAnnotation]:
Get internal types generated by builder.
See also
TypeLiteral().get_sort_key
def get_sort_key() -> str:
Sort literals by name.
TypeLiteral.get_typing_import_record
@staticmethod
def get_typing_import_record() -> ImportRecord:
Get import record required for using Literal.
Fallback to typing_extensions for py38-.
See also
TypeLiteral().inline
@property
def inline() -> bool:
Whether Litereal should be rendered inline.
1-value literals are rendered inline.
TypeLiteral().is_literal
def is_literal() -> bool:
Whether type annotation is Literal
.
TypeLiteral().is_same
def is_same(other: 'TypeLiteral') -> bool:
Check if literals have the same children.
TypeLiteral().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.
TypeLiteral().render_children
def render_children() -> str:
Render literal children to representation.