Skip to content

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

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

Create an empty ImportString.

Signature#

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

ImportString.from_str#

Show source in import_string.py:43

Create from string.

Signature#

@classmethod
def from_str(cls: type[_R], import_string: str) -> _R: ...

ImportString().master_name#

Show source in import_string.py:130

Get first import string part or builtins.

Signature#

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

ImportString.parent#

Show source in import_string.py:59

Get parent ImportString.

Signature#

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

ImportString().render#

Show source in import_string.py:121

Render to string.

Returns#

Ready to use import string.

Signature#

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

ImportString().startswith#

Show source in import_string.py:89

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