Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeStyle] update ruff v0.0.289 and black 23.9.1 #57145

Merged
merged 7 commits into from
Sep 15, 2023

Conversation

gouzil
Copy link
Member

@gouzil gouzil commented Sep 9, 2023

PR types

Others

PR changes

Others

Description

此 PR 工作: 升级ruff 至 v0.0.289 并新增检查, 重新打开PLR1722检查. 由于新版本检查更为严格, 所以在pyproject.toml单独 ignore 文件(后续修复). 同时 ignore ./python/paddle/base/** 为后续引入做准备.

第一阶段

存量统计

升级 ruff 至 v0.0.289 并新增检查

存量 tracking issue

序号 错误码 存量 认领人 完成 PR
1 UP032 873
2 UP018 43
3 B017 15
4 UP028 7
5 F401 2 @gouzil #57145
6 PLR1722 2 @gouzil #57145
7 F811 1 @gouzil #57145

新增

序号 错误码 存量 认领人 完成 PR
1 PLR1711 140
2 NPY003 64
3 PLR1701 51
4 PLW3301 2

Note

在做新增检查的同时可以跟 ./python/paddle/base/** 中的文件一块做
做完后需在 ignore 中删除序号, 或者在 select 中删除注释

第二阶段

ruff

删除 ignore 中的 ./python/paddle/base/** 选项的错误码, 并修复已存在的所有检查

序号 错误码 存量 认领人 完成 PR
1 F401 165
2 UP032 110
3 PLR1711 4
4 PLR1701 13
5 UP031 33
6 C408 28
7 UP030 23
8 F403 11
9 UP028 4
10 PLR1722 4
11 F522 5
12 B010 4
13 F811 3
14 C403 3
15 UP034 3
16 B011 2
17 C405 2
18 C417 2
19 PLR0402 2
20 PLW3301 2
21 B004 1
22 B009 1
23 B016 1
24 B019 1
25 C411 1
26 C416 1
27 F821 1
28 PLC0414 1

flake8

删除 per-file-ignores 中的 # tmp ignore 下对应的错误码, 并修复已存在的所有检查

序号 错误码 存量 认领人 完成 PR
1 E712 14
2 E266 4
3 E714 1
4 E713 1

相关文档

常用命令

# 安装 ruff v0.0.289
pip install ruff==0.0.289
# 本 rule 自动修复方案不合适,因此仅仅跑一下(不加 `--fix`),之后手动修复
ruff --select PLR5501 .
# 手动修复中...

@paddle-bot
Copy link

paddle-bot bot commented Sep 9, 2023

你的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 Sep 9, 2023
# "PLR1701",
# "PLR1711", # Confirmation required
"PLR1722",
# "PLW3301", # Confirmation required
Copy link
Member

Choose a reason for hiding this comment

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

这次不加 NPY003 么

Copy link
Member Author

Choose a reason for hiding this comment

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

加加加

setup.py Outdated Show resolved Hide resolved
@@ -40,6 +39,7 @@ select = [

# NumPy-specific rules
"NPY001",
# "NPY003",
Copy link
Member

Choose a reason for hiding this comment

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

# 本 rule 自动修复方案不合适,因此仅仅跑一下(不加 `--fix`),之后手动修复
ruff --select NPY003 .

NPY003 不适合自动修复么?我随便看了下感觉自动修复效果还可以呀

如果不适合的话,之后需要放到 unfixable 里

Copy link
Member Author

Choose a reason for hiding this comment

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

那只是个例子,不必在意

Copy link
Member

Choose a reason for hiding this comment

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

我都信以为真了,其他开发者肯定也会在意的

Copy link
Member Author

Choose a reason for hiding this comment

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

改好啦

@SigureMo
Copy link
Member

Description 里加一下本 PR 改动了什么的说明吧

Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
@luotao1 luotao1 self-assigned this Sep 11, 2023
@SigureMo SigureMo changed the title [CodeStyle][ruff] update ruff v0.0.287 [CodeStyle][ruff] update ruff v0.0.288 Sep 12, 2023
SigureMo
SigureMo previously approved these changes Sep 12, 2023
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@gouzil gouzil changed the title [CodeStyle][ruff] update ruff v0.0.288 [CodeStyle][ruff] update ruff v0.0.288 and black 23.9.1 Sep 13, 2023
@gouzil gouzil changed the title [CodeStyle][ruff] update ruff v0.0.288 and black 23.9.1 [CodeStyle][ruff] update ruff v0.0.289 and black 23.9.1 Sep 13, 2023
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@luotao1 luotao1 merged commit 21e19ad into PaddlePaddle:develop Sep 15, 2023
@gouzil gouzil changed the title [CodeStyle][ruff] update ruff v0.0.289 and black 23.9.1 [CodeStyle] update ruff v0.0.289 and black 23.9.1 Sep 15, 2023
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
…#57145)

* [CodeStyle][ruff] update ruff v0.0.287

* add NPY003

* Update setup.py

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

* update 288

* update ruff to v0.0.289; update black to 23.9.1; flake8 split ignore python/paddle/base

* fix ignore

* split flake8

---------

Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
@gouzil gouzil deleted the update_ruff_287 branch December 27, 2023 02:48
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.

3 participants