Skip to content

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:19

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().copy#

Show source in type_literal.py:78

Create a copy of type annotation wrapper.

Signature#

def __copy__(self: _R) -> _R: ...

TypeLiteral()._get_import_records#

Show source in type_literal.py:63

Get import record required for using type annotation.

Signature#

def _get_import_records(self) -> set[ImportRecord]: ...

See also#

TypeLiteral().add_child#

Show source in type_literal.py:90

Disabled method to avoid confusion.

Signature#

def add_child(self, child: FakeAnnotation) -> None: ...

See also#

TypeLiteral().get_definition_import_records#

Show source in type_literal.py:72

Get import record required for using Literal.

Signature#

def get_definition_import_records(self) -> set[ImportRecord]: ...

See also#

TypeLiteral().get_local_types#

Show source in type_literal.py:102

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:35

Sort literals by name.

Signature#

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

TypeLiteral().inline#

Show source in type_literal.py:41

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:84

Whether type annotation is Literal.

Signature#

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

TypeLiteral().is_same#

Show source in type_literal.py:96

Check if literals have the same children.

Signature#

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

TypeLiteral().render#

Show source in type_literal.py:50

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

Returns#

A string with a valid type annotation.

Signature#

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

TypeLiteral().render_definition#

Show source in type_literal.py:108

Render type annotation definition.

Signature#

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