Skip to content

[CodeStyle] Bump ast-grep to v0.45.0 and Ruff to v0.16.0 - #79546

Merged
SigureMo merged 3 commits into
PaddlePaddle:developfrom
ShigureNyako:maintenance/bump-ast-grep-ruff-2026-07
Jul 25, 2026
Merged

[CodeStyle] Bump ast-grep to v0.45.0 and Ruff to v0.16.0#79546
SigureMo merged 3 commits into
PaddlePaddle:developfrom
ShigureNyako:maintenance/bump-ast-grep-ruff-2026-07

Conversation

@ShigureNyako

@ShigureNyako ShigureNyako commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

PR Category

Execute Infrastructure

PR Types

Improvements

Description

本 PR 同步升级代码检查工具的新 minor 版本:

  • 将 ast-grep 从 0.44.0 升级到 0.45.0,并同步更新 Codestyle-Check 工作流中的 ast-grep-cli 版本;
  • 将 Ruff 从 0.15.0 升级到 0.16.0
  • 修复 Ruff 0.16 中新稳定的 FURB192 规则发现的 4 处问题。switch_case 中保留原有排序及空输入异常语义,其余位置使用 min/max 直接取得极值;
  • 将 Markdown 明确纳入 ruff-format pre-commit 范围,并格式化 Ruff 0.16 发现的 48 个 Markdown 文件中的 Python 代码块。

上游发布说明:

本地验证:

  • ast-grep 0.45.0: ast-grep test(5/5 通过)及全仓 ast-grep scan 通过;
  • ruff 0.16.0 check --no-cache --force-exclude . 全仓检查通过;
  • ruff 0.16.0 format --check --force-exclude . 全仓检查通过(5525 个 Python/PYI/Jupyter/Markdown 文件);
  • 48 个 Markdown 文件的非代码块正文与 fence 保持不变;61 个可解析 Python 代码块的 AST 保持等价,另有 4 个 docstring 示例及 7 个 pycon/非完整示例由 Ruff 原样负责格式化;
  • 变更文件上的 pre-commit hooks 全部通过(稀疏工作区缺少脚本导致的首次 copyright hook 启动失败,在补齐未修改的脚本后单独验证通过);
  • git diff --check 通过。

是否引起精度变化

@paddle-bot

paddle-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot Bot added the contributor External developers label Jul 25, 2026
@ShigureNyako

Copy link
Copy Markdown
Contributor Author

已完成自 review:

  • 工具 pin 与 Codestyle-Check 中的 ast-grep 安装版本一致;
  • Ruff 0.16 新稳定的 FURB192 仅产生 4 处兼容改动,其中 switch_case 保留原有排序和空输入异常语义;
  • 全仓 Ruff lint/format、ast-grep 5 项规则测试与 scan、变更文件 pre-commit hooks 均已通过;
  • GitHub PR diff 与本地提交 a814b52 一致,未发现额外改动。

@SigureMo 请 review,谢谢。

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已完成首轮代码审查,未发现需要阻塞合入的问题。

本 PR 的版本 pin、pre-commit hook 引用以及 Ruff 自动修复后的等价性检查未发现异常;Codestyle/Pre Commit 已通过,其余仍在运行的平台 CI 请以最终结果为准。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@SigureMo

Copy link
Copy Markdown
Member
uvx ruff@0.16 format        
48 files reformatted, 5476 files left unchanged

直接 format 会不太行,是不是得把 .md 在配置 ignore 掉

@SigureMo

Copy link
Copy Markdown
Member

或者 pre-commit 里把 md 也纳入 ruff format 范围吧,我觉得格式化一下也挺好的

@ShigureNyako

Copy link
Copy Markdown
Contributor Author

已按“纳入 pre-commit”方案处理(0e5dc2e):

  • ruff-format 现在显式包含 markdown
  • 已用 Ruff 0.16 格式化 48 个 Markdown 文件中的 Python 代码块;
  • 全仓 ruff checkruff format --check、ast-grep test/scan 和相关 pre-commit hooks 均通过;
  • 额外核对了格式化结果:Markdown 正文与 fence 未变化,61 个可解析代码块 AST 等价。

PaddlePaddle/docs#7923 继续使用专用 Markdown hooks,因此在 16a0886 中显式 extend-exclude = ["*.md"],避免 Ruff 直接改写 788 个现有文档文件。

@SigureMo 请复查,谢谢。

Comment thread .agents/skills/paddle-op-dev/references/unit-test.md Outdated

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已复查当前 head 的新增提交,Markdown 代码块格式化和 ruff-format 纳入 Markdown 的配置调整未发现需要阻塞合入的问题。

我上次没有留下行级问题,因此没有需要复用或关闭的未解决线程;当前 Pre Commit 已通过,其余平台 CI 仍以最终结果为准。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已复查 8fb2390,这次把 unit-test.md 里的示例恢复为多行调用并保留 trailing comma,前一轮关于格式化方式的意见已经落实,未发现新的问题。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已复查当前 head,代码内容相对上一轮审查没有变化;目前没有新增行级代码问题。

  • P3 优先级:P3
    非行级:PR 描述分类无法附着到 diff 行。
    问题: 当前 PR Category 写成了 User Experience,但本 PR 主要是升级 ast-grep/Ruff、调整 codestyle/pre-commit 配置,并格式化相关 Markdown 代码块;按模板分类更符合 Execute Infrastructure
    影响: 分类与实际改动不一致,会影响后续检索和统计。
    期望处理: 建议将 PR Category 改回 Execute Infrastructure
    处理要求:请针对该评论进行回复(同意并已修改请回复 Done,不同意请说明理由)。
Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@ShigureNyako

Copy link
Copy Markdown
Contributor Author

Done,已将 PR Category 修正为 Execute Infrastructure。代码和 commit 均未改动。

@risemeup1111 risemeup1111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已确认 PR Category 已改回 Execute Infrastructure,上一条非行级建议已解决。当前 head 未新增代码改动,未发现需要阻塞合入的问题。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@f14c723). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             develop    #79546   +/-   ##
===========================================
  Coverage           ?   100.00%           
===========================================
  Files              ?         1           
  Lines              ?         3           
  Branches           ?         0           
===========================================
  Hits               ?         3           
  Misses             ?         0           
  Partials           ?         0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SigureMo
SigureMo merged commit 6e8183f into PaddlePaddle:develop Jul 25, 2026
146 of 152 checks passed
@SigureMo
SigureMo deleted the maintenance/bump-ast-grep-ruff-2026-07 branch July 25, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants