from __future__ import annotations

from types import ModuleType
from typing import MutableMapping, Any


def import_legacy_names(namespace: MutableMapping[str, Any], *modules: ModuleType) -> None:
    """把旧单文件里的全局名字导入到新模块，保证拆分后旧调用链仍可运行。"""
    for module in modules:
        for name in dir(module):
            if name.startswith("__"):
                continue
            namespace[name] = getattr(module, name)
