From f2d30e4911b86ed946ec8eb37479c7f0204eaaeb Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 17 Oct 2026 05:02:39 +0800 Subject: [PATCH] chore(types): gate service base and ratchet 64 type errors --- docs/code-quality.md | 2 +- docs/refactor/optimization-checklist.md | 4 +-- mypy.ini | 1 + .../fixtures/architecture/mypy-baseline.json | 30 +++++-------------- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/docs/code-quality.md b/docs/code-quality.md index 208724c86..cc7b30750 100644 --- a/docs/code-quality.md +++ b/docs/code-quality.md @@ -85,7 +85,7 @@ FastAPI/Click 合同治理移除了 107 条已失效的类型忽略,修正 Ope 债务的文件继续受完整分析的低水位约束,不因装饰器类型恢复而宣称整文件已清零。 2026-10-16 开始逐文件清理类型债务,`app/domain/title.py` 通过局部可空类型声明保留 -既有搜索解析行为,并纳入严格清单;当前清单共 786 个文件(785 个生产文件和 1 个脚本)。 +既有搜索解析行为,并纳入严格清单;当前清单共 787 个文件(786 个生产文件和 1 个脚本)。 每个生产文件完成针对性测试后独立提交,并纳入严格门禁。每批集中同步真实下降的 类型基线和指标文档,运行完整本地单测与适用门禁后统一推送;不逐文件等待远端 CI。 验收同时检查完整严格清单与全宿主 Linux 分析,保证导入接口和全量历史债务都受检查; diff --git a/docs/refactor/optimization-checklist.md b/docs/refactor/optimization-checklist.md index 359bcb6fe..a85ca6b9d 100644 --- a/docs/refactor/optimization-checklist.md +++ b/docs/refactor/optimization-checklist.md @@ -106,9 +106,9 @@ ARCH-201 至 ARCH-204 均达到实现、验证、提交、推送和远端门禁 | Model/Oper 事务债务 | 0 | 自建 Session、自动事务装饰器、直接 commit/rollback 等基线均为零 | | Module Contract | 215 specs / 211 methods / 263 calls | 动态方法名为 0;分类事实富化通过显式合同进入插件调度,旧 YAML 分类方法已移除;download 新增 custom_words 可选参数,旧 provider 签名通过显式合同兼容 | | Event Contract | 53 | 均已有 payload model,但当前全部是 diagnostic enforcement | -| Python 源码量 | 373,281 行 | 本次重新扫描物理行数,排除 `app/plugins/**`;74 个文件超过 1,000 行,12 个超过 2,000 行;源码尺寸仅作观察 | +| Python 源码量 | 373,319 行 | 本次重新扫描物理行数,排除 `app/plugins/**`;74 个文件超过 1,000 行,12 个超过 2,000 行;源码尺寸仅作观察 | | 长方法 | 309 个超过 80 行 | 本次 AST 扫描排除 `app/plugins/**`;61 个超过 150 行,17 个超过 250 行;新增函数仍受 C901/嵌套深度门禁约束 | -| 全量 mypy 历史债务 | 6,417 / 338 文件 | 通知排版补齐 Slack 消息块类型,历史债务减少 2 项;工作流资源过滤改用领域对象调用过滤链,恢复的节点输出在消费前归一化,并收紧可空资源列表的类型低水位;消息媒体交互类型债务已清零,canonical Facade 与 endpoint 类型边界已补齐,低水位只允许继续下降;微信 ClawBot 入站 item_list 媒体解析改为按子项键名分派后,类型错误减少 4 项;站点解析器分享率改用浮点初值,类型错误减少 20 项;本次下载与文件安全修复再减少 3 项;Transmission 进度回退值归一化再减少 2 项,逐文件逐错误码无增长 | +| 全量 mypy 历史债务 | 6,353 / 337 文件 | 通知排版补齐 Slack 消息块类型,历史债务减少 2 项;工作流资源过滤改用领域对象调用过滤链,恢复的节点输出在消费前归一化,并收紧可空资源列表的类型低水位;消息媒体交互类型债务已清零,canonical Facade 与 endpoint 类型边界已补齐,低水位只允许继续下降;微信 ClawBot 入站 item_list 媒体解析改为按子项键名分派后,类型错误减少 4 项;站点解析器分享率改用浮点初值,类型错误减少 20 项;本次下载与文件安全修复再减少 3 项;Transmission 进度回退值归一化再减少 2 项,逐文件逐错误码无增长 | | Ruff 历史诊断 | 98 | 低水位门禁通过,但规则集只覆盖 `E4/E7/E9/F/I` | | 覆盖率固定基线 | Application 80.00%,Domain 80.00% | Chain、Runtime、Agent、Adapter、Startup 未进入包级覆盖率门禁 | diff --git a/mypy.ini b/mypy.ini index 0ffffcf76..b6f28789b 100644 --- a/mypy.ini +++ b/mypy.ini @@ -7,6 +7,7 @@ follow_imports = skip show_error_codes = True pretty = True files = + app/modules/__init__.py, app/runtime/debounce.py, app/modules/vocechat/vocechat.py, app/chain/system.py, diff --git a/tests/fixtures/architecture/mypy-baseline.json b/tests/fixtures/architecture/mypy-baseline.json index e5f314d42..ca52cc13a 100644 --- a/tests/fixtures/architecture/mypy-baseline.json +++ b/tests/fixtures/architecture/mypy-baseline.json @@ -908,23 +908,13 @@ "no-untyped-call": 1, "no-untyped-def": 5 }, - "app/modules/__init__.py": { - "assignment": 1, - "attr-defined": 4, - "empty-body": 4, - "misc": 3, - "no-any-return": 1, - "no-untyped-call": 4, - "no-untyped-def": 7, - "union-attr": 4 - }, "app/modules/_base/downloader.py": { "assignment": 1, "attr-defined": 5 }, "app/modules/_base/mediaserver.py": { "arg-type": 2, - "assignment": 3, + "assignment": 1, "attr-defined": 5, "no-any-return": 1, "no-untyped-def": 2, @@ -954,11 +944,10 @@ "type-arg": 7 }, "app/modules/dingtalk/__init__.py": { - "arg-type": 2, "no-untyped-def": 1 }, "app/modules/discord/__init__.py": { - "arg-type": 9, + "arg-type": 5, "assignment": 10, "attr-defined": 1, "empty-body": 1, @@ -1032,7 +1021,6 @@ "union-attr": 2 }, "app/modules/feishu/module.py": { - "arg-type": 4, "assignment": 6, "attr-defined": 1, "no-untyped-def": 1, @@ -1369,7 +1357,7 @@ "type-arg": 2 }, "app/modules/qqbot/module.py": { - "arg-type": 7, + "arg-type": 4, "assignment": 4, "attr-defined": 1, "empty-body": 1, @@ -1409,7 +1397,7 @@ "union-attr": 48 }, "app/modules/slack/__init__.py": { - "arg-type": 12, + "arg-type": 8, "assignment": 9, "attr-defined": 1, "empty-body": 1, @@ -1434,7 +1422,7 @@ "var-annotated": 1 }, "app/modules/synologychat/__init__.py": { - "arg-type": 5, + "arg-type": 2, "assignment": 4, "attr-defined": 1, "empty-body": 1, @@ -1450,7 +1438,7 @@ "no-untyped-def": 3 }, "app/modules/telegram/module.py": { - "arg-type": 15, + "arg-type": 11, "assignment": 9, "attr-defined": 1, "empty-body": 1, @@ -1622,7 +1610,6 @@ "var-annotated": 2 }, "app/modules/vocechat/__init__.py": { - "arg-type": 3, "assignment": 6, "attr-defined": 1, "empty-body": 1, @@ -1631,7 +1618,6 @@ "union-attr": 1 }, "app/modules/webpush/__init__.py": { - "arg-type": 1, "assignment": 1, "empty-body": 1, "no-untyped-def": 2, @@ -1639,7 +1625,7 @@ "union-attr": 1 }, "app/modules/wechat/__init__.py": { - "arg-type": 8, + "arg-type": 5, "assignment": 5, "attr-defined": 1, "empty-body": 1, @@ -1664,7 +1650,7 @@ "var-annotated": 1 }, "app/modules/wechatclawbot/__init__.py": { - "arg-type": 4, + "arg-type": 1, "assignment": 3, "empty-body": 1, "no-any-return": 1,