Skip to content

Latest commit

 

History

History
278 lines (171 loc) · 4.96 KB

File metadata and controls

278 lines (171 loc) · 4.96 KB

ImportString

Wrapper for python import strings.

Handsdown API Index / Handsdown / Utils / ImportString

Auto-generated documentation for handsdown.utils.import_string module.

ImportString

Show source in import_string.py:9

Wrapper for python import strings.

Arguments

  • value - Import string.

Signature

class ImportString:
    def __init__(self, value: str) -> None: ...

ImportString().add

Show source in import_string.py:39

Add new import part.

Examples

ImportString("my_module") + "MyClass"
ImportString("my_module.MyClass")

ImportString("") + "MyClass"
ImportString("MyClass")

Arguments

  • other - Import string part.

Returns

A new ImportString instance.

Signature

def __add__(self, other: str) -> "ImportString": ...

ImportString().bool

Show source in import_string.py:63

Check if not empty.

Examples

bool(ImportString("my_module"))
True

bool(ImportString(""))
False

Returns

True if not empty.

Signature

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

ImportString().eq

Show source in import_string.py:81

Compare to another ImportString or a string.

Examples

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"
False

Arguments

other - ImportString instance or a string.

Returns

True if import strings are equal.

Signature

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

ImportString().str

Show source in import_string.py:21

Get string value.

Examples

str(ImportString("my_module"))
"my_module"

Returns

Original import string.

Signature

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

ImportString().get_parents

Show source in import_string.py:172

Get all parents.

Returns

A list of ImportString instances.

Signature

def get_parents(self: _R) -> list[_R]: ...

ImportString().is_top_level

Show source in import_string.py:136

Check if import string has no parents.

Returns

True if it has no parents.

Signature

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

ImportString().length

Show source in import_string.py:192

Length of import string parts.

Returns

Length of import string.

Signature

@property
def length(self) -> int: ...

ImportString().name

Show source in import_string.py:203

Last part of the import string.

Signature

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

ImportString().parent

Show source in import_string.py:146

Parent import string.

Returns

A new ImportString instance.

Signature

@property
def parent(self: _R) -> _R: ...

ImportString().parts

Show source in import_string.py:117

Parts of import string splitted by dots.

Examples

ImportString("my_module.MyClass")
["my_module", "MyClass"]

ImportString("")
[]

Returns

A list of import string parts.

Signature

@property
def parts(self) -> list[str]: ...

ImportString().startswith

Show source in import_string.py:162

Check if it starts with import_string.

Returns

True if it is a child.

Signature

def startswith(self: _R, import_string: _R) -> bool: ...