TypeLiteral
mypy-boto3-builder Index / Mypy Boto3 Builder / Type Annotations / TypeLiteral
Auto-generated documentation for mypy_boto3_builder.type_annotations.type_literal module.
TypeLiteral
Show source in type_literal.py:14
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.
Signature
class TypeLiteral(FakeAnnotation):
def __init__(self, name: str, children: Iterable[str]) -> None:
...
See also
TypeLiteral().add_child
Show source in type_literal.py:110
Disabled method to avoid confusion.
Signature
def add_child(self, child: FakeAnnotation) -> None:
...
See also
TypeLiteral().copy
Show source in type_literal.py:98
Create a copy of type annotation wrapper.
Signature
def copy(self) -> "TypeLiteral":
...
TypeLiteral().get_import_record
Show source in type_literal.py:89
Get import record required for using type annotation.
Signature
def get_import_record(self) -> ImportRecord:
...
See also
TypeLiteral().get_local_types
Show source in type_literal.py:122
Get internal types generated by builder.
Signature
def get_local_types(self) -> list[FakeAnnotation]:
...
See also
TypeLiteral().get_sort_key
Show source in type_literal.py:30
Sort literals by name.
Signature
def get_sort_key(self) -> str:
...
TypeLiteral.get_typing_import_record
Show source in type_literal.py:75
Get import record required for using Literal.
Fallback to typing_extensions for py38-.
Signature
@staticmethod
def get_typing_import_record() -> ImportRecord:
...
See also
TypeLiteral().inline
Show source in type_literal.py:36
Whether Litereal should be rendered inline.
1-value literals are rendered inline.
Signature
@property
def inline(self) -> bool:
...
TypeLiteral().is_literal
Show source in type_literal.py:104
Whether type annotation is Literal
.
Signature
def is_literal(self) -> bool:
...
TypeLiteral().is_same
Show source in type_literal.py:116
Check if literals have the same children.
Signature
def is_same(self, other: "TypeLiteral") -> bool:
...
TypeLiteral().render
Show source in type_literal.py:56
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:
...
TypeLiteral().render_children
Show source in type_literal.py:69
Render literal children to representation.
Signature
def render_children(self) -> str:
...