recreate_module
Replaces an existing module in sys.modules with a new LazyModule instance, mapping compatibility modules and object origins while preserving the original module's specification.
def recreate_module(
name: string,
compat_modules: list,
by_module: dict,
direct: dict,
base: class,
**attrs: any
) - > tuple
Replaces an existing module in sys.modules with a LazyModule instance to support lazy loading of sub-modules and attributes.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The fully qualified name of the module to be recreated. |
| compat_modules | list | A list of compatibility module names to be integrated into the new module's namespace. |
| by_module | dict | A mapping of module paths to the attributes they export, used to resolve lazy imports. |
| direct | dict | A dictionary of attributes to be mapped directly to the new module. |
| base | class | The base class used to instantiate the new module, defaulting to LazyModule. |
| **attrs | any | Additional keyword arguments to be set as attributes on the new module. |
Returns
| Type | Description |
|---|---|
tuple | A tuple containing the original module object and the newly created lazy module instance. |