Skip to content

reload.py

Module reloading utilities for development.

This module provides functionality for recursively reloading Python packages and their submodules, maintaining proper dependency order and handling circular imports safely.

The module exposes a simple reload_all() function while hiding the complexity of proper module reloading in the internal _ModuleReloader class.

Example

import nodeweaver nodeweaver.reload_all() # Reloads entire package hierarchy

reload_all(package_name='nodeweaver')

Reload the entire package hierarchy.

This function handles reloading the package and all its submodules in the correct order, managing dependencies and circular imports.

Note

This is primarily intended for development use to reload modified code without restarting Python.

Example

import nodeweaver nodeweaver.reload_all()

Source code in utils/reload.py
def reload_all(package_name: str = 'nodeweaver') -> None:
    """Reload the entire package hierarchy.

    This function handles reloading the package and all its submodules
    in the correct order, managing dependencies and circular imports.

    Note:
        This is primarily intended for development use to reload modified
        code without restarting Python.

    Example:
        >>> import nodeweaver
        >>> nodeweaver.reload_all()
    """
    reloader = _ModuleReloader()
    reloader.reload_package(package_name)