Files
MoviePilot/app/chain/search/__init__.py
DDSRem 2de976f6b3 Merge pull request #7050 from DDSRem-Dev/codex-comment-migration
docs: 统一全项目中文注释和结构化契约说明
2026-10-17 19:26:29 +08:00

37 lines
865 B
Python

"""
搜索 Chain 的惰性稳定公开入口。
"""
from importlib import import_module
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from app.chain.search.facade import SearchChain
_EXPORTS = {
"SearchChain": ("app.chain.search.facade", "SearchChain"),
}
def __getattr__(name: str) -> Any:
"""
首次访问时解析稳定 Chain 类型,避免包初始化形成反向依赖。
"""
contract = _EXPORTS.get(name)
if contract is None:
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
module_name, symbol_name = contract
value = getattr(import_module(module_name), symbol_name)
globals()[name] = value
return value
def __dir__() -> list[str]:
"""
向交互式工具暴露稳定公开面。
"""
return sorted({*globals(), *_EXPORTS})
__all__ = ["SearchChain"]