已合并
fix: pre-commit code #199
RuiWang_创建于 8 天前
fix: pre-commit code #199
已合并
RuiWang_创建于 8 天前
RuiWang_成员
8 天前

当前PR是否有AI参与:

[x] 否
[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :

PR功能描述 / 为什么需要这个合入**:

让全仓代码通过 pre-commit 全套 hook(ruff check + ruff format + codespell + trailing-whitespace / end-of-file-fixer / check-yaml 等基础 hook),共涉及 255 个文件(+9975/-7615)。

修复内容分类

类别 规则 处理方式 数量
真 bug F821 字符串前向注解补 TYPE_CHECKING 导入;删死代码 del cas_mm 13
F811 删 testcase_op.py 被覆盖的重复 @property 2
B012 profiling.py finally 内 return 重构为 try/except 后顺序执行 1
hccl_cascade timeout 主线笔误 timeout 未定义(10 处 F821),提取 _get_timeout() 为变量 10
设计类豁免 B027/B024 可选 hook / 抽象基类加 # noqa 9
E402 backend 文件调换 docstring↔__future__ 顺序;延迟导入加 # noqa 16
F405/F403 import * 展开为显式 import 55
异常处理 E722 except:except Exception: 37
B904 raise Xraise X from e(链式)/ from None(有意屏蔽) 9
未用代码 F401 re-export 导入加冗余别名 import x as x(不改 import * 行为) 35
F841 删确未使用的局部变量赋值 25
B007 未用循环变量 → _ 15
格式化 UP031 % 格式化 → f-string(用 float()/str() 强转保留 printf 语义) 88
E712/E741/E731/B005 等 != True~、模糊名 lci、lambda→def、rstrip 多字符精确化 6
trailing-ws / eof 自动修复 23

codespell 修复

  • .gitcode/ISSUE_TEMPLATE/feature-request.ymlBackgroudBackground(真错字)
  • codespell 忽略列表加 dOut(数据术语 derivative output,误报)

该PR关联的issue

(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #

希望检视人员了解:

  • 非纯格式化:除格式化外混入了 37 处 except:except Exception: + 9 处 from e/from None 的异常处理变更(E722/B904,ruff 无自动修复,手动逐处确认语义安全),以及 10 处 hccl_cascade timeout bug 修复。
  • F841/B007 为 unsafe fix:项目 pre-commit 配置未启用 --unsafe-fixes,这些删除/改名是手动执行并逐一确认变量确实未使用。
  • printf→f-string 保语义%-14.18f{float(x):<14.18f}(加 float() 强转,因为 ml_dtypes.int4 的 printf 会强转但 f-string :f 不会),输出逐字节一致。
  • re-export 用冗余别名:11 个 __init__.py / shim 模块的 F401 修复用 import x as x 而非 __all__,完全不改 from module import * 行为。

测试

  • pre-commit 9 hook 全 Passed
  • ruff check / ruff format 全绿
  • 1321 个非设备测试通过(0 失败,20 skip 为预存在的 torch_npu/tf 冲突)
  • ttk 全模块 walk-import 冒烟通过(唯一失败 executor_main 为预存在的运行时依赖)

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 RuiWang_ 的贡献)
RRuiWang_成员
8 天前 创建了 pull request,commit 35cc3738
RRuiWang_成员
8 天前 update merge request[project id: 9872633, iid: 199, commit_id: 441b7c27c6bd85abe874351923660e97132b5c79] virtual merging success
RRuiWang_成员
8 天前 强制推送  4 个提交:35cc3738-3 commits from branch master65b4c46e-fix: pre-commit all
RRuiWang_成员
8 天前 update merge request[project id: 9872633, iid: 199, commit_id: ffebc99aa652000dda982e0b3e4adf7530892fc0] virtual merging success
CANN-robotCANN-robot成员
8 天前 添加了label:cann-cla/yes
此处折叠了42条消息 查看更多
CANN-robot
CANN-robot成员
8 天前 评论:

The following label is not ready.

approved: Please wait for committers to review the code.

likedislike
chenqi317成员
8 天前 评论:

/lgtm
/approve

likedislike
songchangxia成员
8 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
8 天前 添加了label:approved
CANN-robotCANN-robot成员
8 天前 合入了pull request