fix(ai): 修 ruff lint 三处错误——CI 由红转绿
CI / ai-gates (push) Successful in 31s

`4762358` 与 `86d63ab` 两次 CI 均因 `ruff check` 失败而红。

**根因是我的门禁自查方法错了**:用 `ruff check . | tail -1; echo $?` 读到的是
`tail` 的退出码而不是 ruff 的,于是把一次真实的 lint 失败读成了通过——先前声称
的「四道门禁全绿」是基于这个坏掉的检查得出的。已在 ci.yml 的 Gates 步骤就地注明
此坑,并改为逐条分开跑读各自退出码。

三处都是实际问题,非误报:
- `client.py:138` PYI034:`__enter__` 的返回注解硬编码为类名,应为 `Self`
  (子类化后注解会失准)
- `test_video.py:58` C408:`dict()` 调用改字面量
- `test_layering.py:85` PIE810:两次 `endswith` 合并为一次元组调用

修复后在与 CI 同构的隔离 venv(同镜像源、同 requirements-dev.txt,实测 ruff
版本与本地一致 0.16.8)逐道复验:secret-scan / format / lint / pytest 四道
退出码均为 0,100 测试全过。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-20 12:36:17 +08:00
parent 86d63ab1cb
commit db87d66403
4 changed files with 13 additions and 9 deletions
+4
View File
@@ -51,6 +51,10 @@ jobs:
if [ -f requirements.txt ]; then pip install -q -r requirements.txt; fi
# 与本地门禁同一套命令。ruff 兼任 format 检查与 lint,
# 对应 patbond-flutter 的 dart format + flutter analyze 两步。
#
# 本地自查时注意:`ruff check . | tail -1; echo $?` 读到的是 **tail** 的
# 退出码,不是 ruff 的——这样会把一次真实的 lint 失败读成通过(本仓已因此
# 红过一次)。逐条分开跑,或用 ${PIPESTATUS[0]}。
- name: Gates
run: |
python --version