mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
refactor(chain): 处理链功能域 mixin 化,清理未使用导入并根治兼容层循环导入
- ChainBase 拆分为 RecognitionMixin/MessageProcessingMixin/NotificationMixin - TransferChain 拆分为 7 个功能 mixin(_mixins.py),SubscribeChain 音乐订阅域拆出 _music.py - 斜杠命令交互四件套收敛为 InteractionChainMixin 委托,会话管理器移至 application 层,chain 层不再 re-export - 模块基础类收敛到 app/modules/_base(notification/mediaserver 语义重命名) - 清理 app/chain/__init__.py 24 个未使用导入,修正 49 处测试 patch 目标到实际命名空间 - 兼容层 legacy 符号不再并入 __all__,根治 schemas 初始化反向拉起 application.transfer 的循环导入 - 修复 bangumi 集数为字符串时 set_bangumi_info 抛 TypeError - 新增重复代码等架构门禁测试;capability 清单校验排除下划线内部目录
This commit is contained in:
@@ -188,11 +188,14 @@ class LegacySymbolOverlayLoader(importlib.abc.Loader):
|
||||
|
||||
module.__getattr__ = resolve_export
|
||||
module.__dir__ = list_exports
|
||||
# 兼容符号不并入 __all__:避免 `from <module> import *` 在包初始化期
|
||||
# 急切解析旧符号、反向拉起应用层模块形成循环导入;显式导入与属性
|
||||
# 访问仍由上方 __getattr__ 惰性解析兜底
|
||||
public_names = {
|
||||
name for name in module.__dict__ if not name.startswith("_")
|
||||
}
|
||||
declared_exports = set(previous_all or ()) if had_all else public_names
|
||||
module.__all__ = sorted(declared_exports | set(exports))
|
||||
module.__all__ = sorted(declared_exports)
|
||||
module.__dict__[self._STATE_KEY] = {
|
||||
"__getattr__": previous_getattr,
|
||||
"__dir__": previous_dir,
|
||||
|
||||
@@ -680,6 +680,18 @@ PACKAGE_EXPORTS: Dict[str, Dict[str, SymbolAlias]] = {
|
||||
# 物理模块仍存在、仅部分公开符号迁走时,由导入器在标准 Loader 执行后叠加惰性符号路由。
|
||||
# canonical 源码不反向依赖兼容层,目标符号也只在旧调用方真正取用时加载。
|
||||
SYMBOL_ALIASES: Dict[str, Dict[str, SymbolAlias]] = {
|
||||
"app.agent.orchestrator": {
|
||||
"AgentChain": SymbolAlias(
|
||||
target_module="app.chain.agent",
|
||||
target_name="AgentChain",
|
||||
replacement="app.chain.agent.AgentChain",
|
||||
),
|
||||
"ReplyMode": SymbolAlias(
|
||||
target_module="app.schemas.agent",
|
||||
target_name="ReplyMode",
|
||||
replacement="app.schemas.agent.ReplyMode",
|
||||
),
|
||||
},
|
||||
"app.chain.message": {
|
||||
"MediaInteractionChain": SymbolAlias(
|
||||
target_module="app.chain.interaction",
|
||||
|
||||
Reference in New Issue
Block a user