ImportString

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

Wrapper for Python import strings.

ImportString

[find in source code]

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

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'

ImportString.empty

[find in source code]

@classmethod
def empty() -> _R:

Create an empty ImportString.

ImportString.from_str

[find in source code]

@classmethod
def from_str(import_string: str) -> 'ImportString':

Create from string.

ImportString().master_name

[find in source code]

@property
def master_name() -> str:

Get first import string part or builtins.

ImportString.parent

[find in source code]

@classmethod
def parent() -> _R:

Get parent ImportString.

ImportString().render

[find in source code]

def render() -> str:

Render to string.

Returns

Ready to use import string.

ImportString().startswith

[find in source code]

def startswith(other: _R) -> bool:

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.