Wrapper for python import strings.
Handsdown API Index / Handsdown / Utils / ImportString
Auto-generated documentation for handsdown.utils.import_string module.
Show source in import_string.py:9
Wrapper for python import strings.
value- Import string.
class ImportString:
def __init__(self, value: str) -> None: ...Show source in import_string.py:39
Add new import part.
ImportString("my_module") + "MyClass"
ImportString("my_module.MyClass")
ImportString("") + "MyClass"
ImportString("MyClass")other- Import string part.
A new ImportString instance.
def __add__(self, other: str) -> "ImportString": ...Show source in import_string.py:63
Check if not empty.
bool(ImportString("my_module"))
True
bool(ImportString(""))
FalseTrue if not empty.
def __bool__(self) -> bool: ...Show source in import_string.py:81
Compare to another ImportString or a string.
ImportString("my_module.MyClass") == ImportString("my_module.MyClass")
True
ImportString("my_module.MyClass") == ImportString("my_module.OtherClass")
False
ImportString("my_module.MyClass") == "my_module.MyClass"
True
ImportString("my_module.MyClass") == "my_module"
False
ImportString("my_module.MyClass") == b"my_module.MyClass"
Falseother - ImportString instance or a string.
True if import strings are equal.
def __eq__(self, other: object) -> bool: ...Show source in import_string.py:21
Get string value.
str(ImportString("my_module"))
"my_module"Original import string.
def __str__(self) -> str: ...Show source in import_string.py:172
Get all parents.
A list of ImportString instances.
def get_parents(self: _R) -> list[_R]: ...Show source in import_string.py:136
Check if import string has no parents.
True if it has no parents.
def is_top_level(self) -> bool: ...Show source in import_string.py:192
Length of import string parts.
Length of import string.
@property
def length(self) -> int: ...Show source in import_string.py:203
Last part of the import string.
@property
def name(self) -> str: ...Show source in import_string.py:146
Parent import string.
A new ImportString instance.
@property
def parent(self: _R) -> _R: ...Show source in import_string.py:117
Parts of import string splitted by dots.
ImportString("my_module.MyClass")
["my_module", "MyClass"]
ImportString("")
[]A list of import string parts.
@property
def parts(self) -> list[str]: ...Show source in import_string.py:162
Check if it starts with import_string.
True if it is a child.
def startswith(self: _R, import_string: _R) -> bool: ...