pythonwrench.importlib module

class pythonwrench.importlib.Placeholder(*args, **kwargs)[source]

Bases: object

Placeholder object. All instances attributes always returns the object itself.

pythonwrench.importlib.is_available_package(package: str) bool[source]

Returns True if package is installed in the current python environment.

pythonwrench.importlib.is_editable_package(package: str) bool[source]

Returns True if package is installed in editable mode in the current python environment.

pythonwrench.importlib.reload_editable_packages(*, verbose: int = 0) list[ModuleType][source]

Reload all submodules of editable packages already imported.

pythonwrench.importlib.reload_submodules(*modules: ModuleType, verbose: int = 0, only_editable: bool = True, only_loaded: bool = False) list[ModuleType][source]

Reload all submodule recursively.

pythonwrench.importlib.requires_packages(arg0: Iterable[str] | str, /, *args: str) Callable[[Callable[[P], T]], Callable[[P], T]][source]

Decorator to wrap a function and raises an error if the function is called.

Example

>>> @requires_packages("pandas")
>>> def f(x):
>>>     return x
>>> f(1)  # raises ImportError if pandas is not installed
pythonwrench.importlib.search_submodules(root: ModuleType, only_editable: bool = True, only_loaded: bool = False) list[ModuleType][source]

Return the submodules already imported.