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

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

Show source in import_string.py:99

Create a new import string by adding another import string parts to the end.

Signature#

def __add__(self: Self, other: Self | str) -> Self: ...

ImportString().bool#

Show source in import_string.py:67

Whether import string is not empty.

Signature#

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

ImportString().eq#

Show source in import_string.py:85

Whether import strings produce the same render.

Signature#

def __eq__(self, other: object) -> bool: ...

ImportString().gt#

Show source in import_string.py:91

Compare import strings for sorting.

Emulates isort logic.

Signature#

def __gt__(self, other: object) -> bool: ...

ImportString().hash#

Show source in import_string.py:79

Calculate hash value based on all parts.

Signature#

def __hash__(self) -> int: ...

ImportString().str#

Show source in import_string.py:73

Render as a part of a valid Python import statement.

Signature#

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

ImportString.empty#

Show source in import_string.py:49

Create an empty ImportString.

Signature#

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

ImportString.from_str#

Show source in import_string.py:42

Create from string.

Signature#

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

ImportString().master_name#

Show source in import_string.py:149

Get first import string part or builtins.

Signature#

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

ImportString.parent#

Show source in import_string.py:58

Get parent ImportString.

Signature#

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

ImportString().render#

Show source in import_string.py:140

Render to string.

Returns#

Ready to use import string.

Signature#

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

ImportString().startswith#

Show source in import_string.py:108

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: Self, other: Self) -> bool: ...