Skip to content

Commit dce5c33

Browse files
authored
[CodeStyle] Bump ruff to 0.5.0, and update codestyle docs (#6736)
1 parent db09700 commit dce5c33

File tree

8 files changed

+21
-17
lines changed

8 files changed

+21
-17
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
files: \.md$|\.rst$
2727
# For Python files
2828
- repo: https://github.com/astral-sh/ruff-pre-commit
29-
rev: v0.3.5
29+
rev: v0.5.0
3030
hooks:
3131
- id: ruff
3232
args: [--fix, --exit-non-zero-on-fix, --no-cache]

ci_scripts/doc-build-config/en/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
# General information about the project.
2828
project = "PaddlePaddle"
29-
author = "%s developers" % project
29+
author = f"{project} developers"
3030
copyright = "%d, %s" % (time.localtime(time.time()).tm_year, author)
3131
github_doc_root = "https://github.com/PaddlePaddle/docs/docs"
3232

@@ -231,7 +231,7 @@
231231
# (source start file, target name, title,
232232
# author, documentclass [howto, manual, or own class]).
233233
latex_documents = [
234-
(master_doc, "%s.tex" % project, project, author, "manual"),
234+
(master_doc, f"{project}.tex", project, author, "manual"),
235235
]
236236
numfig = True
237237
highlight_language = "python"

ci_scripts/doc-build-config/zh/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
templates_path = ["/templates"]
3131

3232
project = "PaddlePaddle"
33-
author = "%s developers" % project
33+
author = f"{project} developers"
3434
copyright = "%d, %s" % (time.localtime(time.time()).tm_year, author)
3535
github_doc_root = "https://github.com/PaddlePaddle/docs/docs"
3636

@@ -270,7 +270,7 @@
270270
# (source start file, target name, title,
271271
# author, documentclass [howto, manual, or own class]).
272272
latex_documents = [
273-
(master_doc, "%s.tex" % project, project, author, "manual"),
273+
(master_doc, f"{project}.tex", project, author, "manual"),
274274
]
275275

276276
# Use the .. admonition:: directive for Notes sections.

docs/api/gen_alias_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def _find_real_api_by_grep_file(self, api_list):
8787

8888
obj = eval(api)
8989
if inspect.isclass(obj):
90-
reg = "class %s(" % api.split(".")[-1]
90+
reg = "class {}(".format(api.split(".")[-1])
9191
elif inspect.isfunction(obj):
92-
reg = "def %s(" % api.split(".")[-1]
92+
reg = "def {}(".format(api.split(".")[-1])
9393

9494
shell_cmd = f"find {self.paddle_root_path} -name '*.py' | xargs grep \"{reg}\" "
9595

docs/dev_guides/code_contributing_path_cn.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ Tabs remover (C++)...................................(no files to check)Skipped
164164
Tabs remover (Python)....................................................Passed
165165
copyright_checker........................................................Passed
166166
black....................................................................Passed
167-
flake8...................................................................Passed
168167
ruff.....................................................................Passed
169168
clang-format.........................................(no files to check)Skipped
170169
cpplint..............................................(no files to check)Skipped

docs/dev_guides/docs_contributing_guides_cn.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,9 @@ fix end of files.........................................................Passed
120120
trim trailing whitespace.................................................Passed
121121
CRLF end-lines remover...................................................Passed
122122
Tabs remover.............................................................Passed
123-
CN-[whitespace]-EN fixer.................................................Passed
124-
convert jinja2 into html.............................(no files to check)Skipped
125-
convert-markdown-into-html...........................(no files to check)Skipped
126-
black................................................(no files to check)Skipped
127-
ruff.................................................(no files to check)Skipped
123+
CN-[whitespace]-EN fixer.............................(no files to check)Skipped
124+
ruff.....................................................................Passed
125+
ruff-format..............................................................Passed
128126
[my-cool-stuff ee8f4441f] fix docs bugs
129127
1 file changed, 19 insertions(+), 34 deletions(-)
130128
```

docs/dev_guides/git_guides/codestyle_check_guide_cn.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Tabs remover (C++).......................................................Passed
4343
Tabs remover (Python)................................(no files to check)Skipped
4444
copyright_checker........................................................Passed
4545
black................................................(no files to check)Skipped
46-
flake8...............................................(no files to check)Skipped
4746
ruff.................................................(no files to check)Skipped
4847
clang-format.............................................................Failed
4948
- hook id: clang-format
@@ -85,7 +84,7 @@ Date: xxx
8584
| [Lucas-C/pre-commit-hooks](https://github.com/Lucas-C/pre-commit-hooks.git) | 社区维护的一些通用的 hook,含将 CRLF 改为 LF、移除 Tab 等 hook | 1.5.1 |
8685
| [copyright_checker](https://github.com/PaddlePaddle/Paddle/blob/develop/tools/codestyle/copyright.hook) | Copyright 检查 | 本地脚本 |
8786
| [black](https://github.com/psf/black) | Python 代码格式化 | 23.3.0 |
88-
| [ruff](https://github.com/astral-sh/ruff) | Python 代码风格检查 | 0.3.5 |
87+
| [ruff](https://github.com/astral-sh/ruff) | Python 代码风格检查 | 0.5.0 |
8988
| [clang-format](https://github.com/llvm/llvm-project/tree/main/clang/tools/clang-format) | C++ 代码格式化 | 13.0.0 |
9089
| [cpplint](https://github.com/cpplint/cpplint) | C++ 代码风格检查 | 1.6.0 |
9190
| [clang-tidy](https://github.com/llvm/llvm-project/tree/main/clang-tools-extra/clang-tidy) | C++ 代码风格检查 | 15.0.2.1 |

pyproject.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ select = [
2323
# Pyupgrade
2424
"UP",
2525

26+
# Flake8-pyi
27+
"PYI",
28+
2629
# NumPy-specific rules
2730
"NPY001",
2831
"NPY003",
@@ -52,19 +55,24 @@ select = [
5255

5356
# Pylint
5457
"PLE",
55-
"PLC0414",
5658
"PLC3002",
5759
"PLR0206",
5860
"PLR0402",
59-
"PLR1701",
6061
"PLR1711",
6162
"PLR1722",
6263
"PLW3301",
6364

65+
# Flake8-simplify
66+
"SIM101",
67+
6468
# Pygrep-hooks
6569
"PGH004",
6670

71+
# Flake8-type-checking
72+
"TCH",
73+
6774
# Ruff-specific rules
75+
"RUF010",
6876
"RUF100",
6977
]
7078
unfixable = [

0 commit comments

Comments
 (0)