ImportString

mypy-boto3-builder Index / Mypy Boto3 Builder / Import Helpers / ImportString

Auto-generated documentation for mypy_boto3_builder.import_helpers.import_string module.

ImportString

Show source in import_string.py:9

Wrapper for Python import strings.

Arguments

  • master - Master module name
  • parts - Other import parts

Examples

import_string = ImportString("my", "name")

str(import_string)
'my.name'

import_string.render()
'my.name'

import_string.parts.append('test')
import_string.render()
'my.name.test'

Signature

class ImportString:
    def __init__(self, master_name: str, *parts: str) -> None:
        ...

ImportString.empty

Show source in import_string.py:47

Create an empty ImportString.

Signature

@classmethod
def empty(cls: type[_R]) -> _R:
    ...

ImportString.from_str

Show source in import_string.py:40

Create from string.

Signature

@classmethod
def from_str(cls, import_string: str) -> "ImportString":
    ...

ImportString().master_name

Show source in import_string.py:126

Get first import string part or builtins.

Signature

@property
def master_name(self) -> str:
    ...

ImportString.parent

Show source in import_string.py:56

Get parent ImportString.

Signature

@classmethod
def parent(cls: type[_R]) -> _R:
    ...

ImportString().render

Show source in import_string.py:117

Render to string.

Returns

Ready to use import string.

Signature

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

ImportString().startswith

Show source in import_string.py:85

Check if import string starts with other.

Examples

ImportString('my', 'name').startswith(ImportString('my'))
True

ImportString('my_module', 'name').startswith(ImportString('my'))
False

ImportString('my', 'name').startswith(ImportString('my, 'name'))
True

ImportString('my', 'name').startswith(ImportString.empty())
True

Arguments

  • other - Other import string.

Signature

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