Merged
style: ruff 配置行宽 120 并关闭 magic trailing comma #6286
zhangyujia77Add on Sep 21
style: ruff 配置行宽 120 并关闭 magic trailing comma #6286
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for zhangyujia77's contribution.)Sep 21 Created pull request, commit 4257ff1b
atomgit-bot
Sep 21 Comments:
Sep 21 Comments:
🤖 正在生成合并请求摘要,请稍候…


Incorrect?
atomgit-bot
Sep 21 Comments:
Sep 21 Comments:
🤖 AI 代码检视正在进行中,请稍候…


Incorrect?
Sep 21 Added label: cann-cla/yes
CANN-robot
Sep 21 Comments:
Sep 21 Comments:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| cmake | ✅ 诸葛洵, hujiawen_kaven (2/2) | ✅ 诸葛洵 (1/1) |
| docs | ✅ ai_xin, 诸葛洵, hujiawen_kaven (3/2) | ✅ ai_xin (1/1) |
| examples | ✅ 诸葛洵, ai_xin, hujiawen_kaven (3/2) | ✅ ai_xin, 诸葛洵 (2/1) |
| repo-cann/asc-devkit | ✅ 诸葛洵, hujiawen_kaven (2/2) | ✅ 诸葛洵, hujiawen_kaven (2/1) |
| scripts | ✅ 诸葛洵, hujiawen_kaven (2/2) | ✅ 诸葛洵 (1/1) |
| tools | ✅ 诸葛洵, hujiawen_kaven (2/2) | ✅ 诸葛洵 (1/1) |
| tools/build | ✅ hujiawen_kaven, 诸葛洵 (2/2) | ✅ hujiawen_kaven (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhangyujia77, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Sep 21 Set zengjuan,zhanghao_0689,suqwe,kevin365,wulinyu,qin437231,kong0808,dengjing_aoe,YeZZzzz1,bluesky901,yangbinhua,zhudi22,chenyiyuan,xun_zhuge,XuebinYang,sjtulxh,bianque,houyuyang,Lycheeeee,YANXI_ZHAO,chentianyu19,shi_nanxiang,wuyang_hw,jiangxinyu3,munanhw,ai_xin,ascendhjh,hujiawen_kaven,wangxiaozhi,DragonBornHD84,louyuxuan,changxianyu,hyolee,yukangchen as approver
Sep 21 Set zengjuan,zhanghao_0689,suqwe,kevin365,wulinyu,qin437231,kong0808,dengjing_aoe,YeZZzzz1,bluesky901,yangbinhua,zhudi22,chenyiyuan,xun_zhuge,XuebinYang,sjtulxh,bianque,houyuyang,Lycheeeee,YANXI_ZHAO,chentianyu19,shi_nanxiang,wuyang_hw,jiangxinyu3,munanhw,ai_xin,ascendhjh,hujiawen_kaven,wangxiaozhi,DragonBornHD84,louyuxuan,changxianyu,hyolee,yukangchen as approver
11 event messages are collapsed here。 See more
Sep 21 Added label: cann-cla/yes
zhangyujia77
Sep 21 Comments:
Sep 21 Comments:
compile


Sep 21 Pre merge succeeded (commit_id: 93640b09519f015c0bc701ab2c6fd5c30aa20663)
Sep 21 Modify description of pull request
CANN-robot
Sep 21 Comments:
Sep 21 Comments:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


Sep 21 Added label: ci-pipeline-running
Sep 21 Modify description of pull request
zhugexun_sjtu
Sep 21 Comments:
Sep 21 Comments:
/lgtm


zhugexun_sjtu
Sep 21 Comments:
Sep 21 Comments:
/approve


hujiawen_kaven
Sep 21 Comments:
Sep 21 Comments:
/approve
/lgtm


Sep 21 Added label: lgtm
ai_xin
Sep 21 Comments:
Sep 21 Comments:
/approve


Sep 21 Added label: approved
Sep 21 Removed label: ci-pipeline-running
Sep 21 Added label: ci-pipeline-passed
Sep 21 Merged pull request
描述
ruff.toml 新增两项配置并据此重排全仓 Python 代码:
为什么改 line-length
ruff 的
line-length此前从未在仓库任何地方配置过 ——ruff.toml只设了target-version,全仓搜line-length零命中,pre-commit 的 ruff hook 也没传参。所以生效值 88 是 ruff 内置默认(沿用 Black 的约定),不是评估过的技术决策:
120 有三层依据:
.clang-format: ColumnLimit: 120。同一仓库 C++ 120、Python 88 本身不一致。pyasc、pypto、pto-isa、ops-test-kit、vllm-ascend(ruff),torch_npu、pytorch(flake8)。asc-devkit 是其中唯一没配的。88 列会把多参数调用强制拆成逐参数一行,一条语句常常变 3-5 行:
# 前(1 行) raise RuntimeError("Length of ASCENDC_TPL_UINT_{} {} is too short.".format(self.macro_type, self.name)) # 后(5 行) raise RuntimeError( "Length of ASCENDC_TPL_UINT_{} {} is too short.".format( self.macro_type, self.name ) )为什么关 magic trailing comma
末尾逗号会让 ruff-format 强制保持展开,即使该行放得下。统计范围内现存 886 处此类逗号,绝大多数是 88 列时期 ruff 自己折行时补上的,并非作者意图 ——换到 120 列后这些调用本可收拢,却因那个自动留下的逗号继续保持展开。
关联的Issue
测试
文档更新
类型标签