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'].

TypeLiteral

[find in source code]

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

[find in source code]

def add_child(child: FakeAnnotation) -> None:

Disabled method to avoid confusion.

See also

TypeLiteral().copy

[find in source code]

def copy() -> 'TypeLiteral':

Create a copy of type annotation wrapper.

TypeLiteral().get_import_record

[find in source code]

def get_import_record() -> ImportRecord:

Get import record required for using type annotation.

See also

TypeLiteral().get_local_types

[find in source code]

def get_local_types() -> list[FakeAnnotation]:

Get internal types generated by builder.

See also

TypeLiteral().get_sort_key

[find in source code]

def get_sort_key() -> str:

Sort literals by name.

TypeLiteral.get_typing_import_record

[find in source code]

@staticmethod
def get_typing_import_record() -> ImportRecord:

Get import record required for using Literal.

Fallback to typing_extensions for py38-.

See also

TypeLiteral().inline

[find in source code]

@property
def inline() -> bool:

Whether Litereal should be rendered inline.

1-value literals are rendered inline.

TypeLiteral().is_literal

[find in source code]

def is_literal() -> bool:

Whether type annotation is Literal.

TypeLiteral().is_same

[find in source code]

def is_same(other: 'TypeLiteral') -> bool:

Check if literals have the same children.

TypeLiteral().render

[find in source code]

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

[find in source code]

def render_children() -> str:

Render literal children to representation.