common.reflection.ref
DummyModule Objects
class DummyModule(ModuleType)
A dummy module from which you can import anything
import_module_with_missing
def import_module_with_missing(
name: str, missing_modules: Tuple[str, ...] = ()) -> ModuleType
Module importer that ignores missing modules by importing a dummy module
object_from_ref
def object_from_ref(
ref: str,
typechecker: Callable[[Any], Any],
raise_exec_errors: bool = False,
import_missing_modules: bool = False) -> Tuple[Any, ImportTrace]
Splits ref on module.attr and import module, then gets attr and runs typechecker on it.
If import_missing_modules
is True, will use custom importer that replaces missing modules with dummy
from which you can import anything.
NOTE: if your import got patched it will not work. Use this only to import refs ie. to verify if they exist, not in production code
if raise_exec_errors
, all errors that happen when code of the imported module is executed are raised, otherwise corresponding trace is returned
Returns: a tuple (typechecked attr, trace if error)