fix(ci): auto-fix 脚本补充 ruff check --fix(F401 等可自动修复) #1847
Reference in New Issue
Block a user
Delete Branch "fix/ci-autofix-ruff"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
Validate - Style 的 auto-fix 步骤(
scripts/ci/auto_fix_formatting.py)只跑 black/isort/prettier,漏了ruff check --fix。导致 F401(未使用 import)等 ruff 可自动修复的 lint 错误在 CI 报红后无法自动推修复,开发者反复被打回(近期 #49049/#49041/#49018 三个 PR 均因此卡 Style)。改动
fix_python()在 black/isort 之后追加ruff check <targets> --fix --unsafe-fixes:--unsafe-fixes用于启用 F401 等 ruff 归类为 unsafe 的自动修复(否则 F401 不会被自动修);安全性由修复后重跑的完整 CI(单测/构建/staging 健康检查+回滚)兜底。validate_style.sh的检查范围对齐:apps packages tests(alembic 在 pyproject.toml 中被 ruff exclude,scripts 不在 ruff 检查范围内,均不做修复)。style: auto-format with black + isort + ruff + prettier([skip ci-format-check]防循环标记不变)。Auto-fix formatting (black + isort + ruff)。验证
py_compile语法检查通过;改动后的脚本本身ruff check全过。影响面
仅 CI 自动化脚本,不碰业务代码。合并后所有 PR/push 的 Style 失败会自动修复 ruff 可修复项并推回分支。
🚀 预览环境已部署
🗑️ 预览环境已清理
PR #1847 已关闭或合并,对应的预览环境已被清理。