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
+6 -6
View File
@@ -55,12 +55,12 @@ def provider_with(handler, **kwargs) -> SeedanceVideoProvider:
def video_request(**kwargs) -> GenerationRequest:
defaults = dict(
job_id="job-1",
media_kind=MediaKind.VIDEO,
model="doubao-seedance-x",
prompt="一只猫",
)
defaults = {
"job_id": "job-1",
"media_kind": MediaKind.VIDEO,
"model": "doubao-seedance-x",
"prompt": "一只猫",
}
return GenerationRequest(**{**defaults, **kwargs})
+1 -1
View File
@@ -82,7 +82,7 @@ class TestTransportStaysBusinessAgnostic:
offenders = {
name
for name in imports_of(APP / "providers" / "volcengine" / "client.py")
if name.endswith((".video", ".image")) or name.endswith("models")
if name.endswith((".video", ".image", "models"))
}
assert not offenders, f"传输层不应依赖具体业务模块:{offenders}"