refactor(types): govern scheduler initializer instance lookup

This commit is contained in:
jxxghp
2026-10-16 11:32:06 +08:00
parent 1d51fc09aa
commit a696d47fd0
3 changed files with 5 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
"""调度器业务能力装配与生命周期入口。"""
import asyncio
from typing import Awaitable, Optional
from typing import Awaitable, Callable, Optional
from app.application.agenttask import AgentTaskRepository
from app.application.image import WallpaperHelper
@@ -33,8 +33,8 @@ def reset_scheduler_runtime() -> None:
def reset_scheduler_bindings() -> None:
"""在 Scheduler 已停止后撤销当前 lifespan 的仓储、业务能力和类登记。"""
# Singleton 元类保留旧动态接口,当前 owner 在此精确收窄为 Scheduler。
scheduler = Scheduler.get_existing_instance() # type: ignore[no-untyped-call]
existing_scheduler: Callable[[], Optional[Scheduler]] = Scheduler.get_existing_instance
scheduler = existing_scheduler()
if scheduler is not None:
scheduler.reset_runtime_bindings()
reset_scheduler_runtime()

View File

@@ -75,7 +75,7 @@ uv run --locked --no-sync python scripts/architecture/complexity.py
回调和返回值类型;全仓错误计数为零并不保证单独纳入 strict frontier 后也为零。
2026-10-16 开始逐文件清理类型债务,`app/domain/title.py` 通过局部可空类型声明保留
既有搜索解析行为,并纳入严格清单;当前清单共 59 个文件(58 个生产文件和 1 个脚本)。
既有搜索解析行为,并纳入严格清单;当前清单共 60 个文件(59 个生产文件和 1 个脚本)。
每个治理提交聚焦一个生产文件及其必要测试、门禁配置、真实下降基线和指标文档。
验收同时检查完整严格清单与全宿主 Linux 分析,避免 `follow_imports = skip` 隐藏依赖
签名冲突;不通过忽略诊断或放宽类型合同接受回退。最新文件清单以 `mypy.ini` 为准,

View File

@@ -57,6 +57,7 @@ files =
app/db/uow.py,
app/startup/composition/context.py,
app/startup/composition/configuration.py,
app/startup/initializers/scheduler.py,
app/startup/lifecycle/components.py,
app/scheduler/registry.py,
app/db/adapters/outbox.py,