ImportString
Auto-generated documentation for mypy_boto3_builder.import_helpers.import_string module.
Wrapper for Python import strings.
- mypy-boto3-builder / Modules / Mypy Boto3 Builder / Import Helpers / ImportString
ImportString
class ImportString():
def __init__(master_name: str, *parts: str) -> None:
Wrapper for Python import strings.
Arguments
master
- Master module nameparts
- 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
@classmethod
def empty() -> _R:
Create an empty ImportString.
ImportString.from_str
@classmethod
def from_str(import_string: str) -> 'ImportString':
Create from string.
ImportString().master_name
@property
def master_name() -> str:
Get first import string part or builtins
.
ImportString.parent
@classmethod
def parent() -> _R:
Get parent ImportString.
ImportString().render
def render() -> str:
Render to string.
Returns
Ready to use import string.
ImportString().startswith
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.