Skip to content

Commit

Permalink
[CodeStyle] Bump ruff to 0.5.0, and update codestyle docs (PaddlePadd…
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo authored Jul 1, 2024
1 parent db09700 commit dce5c33
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
files: \.md$|\.rst$
# For Python files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.5.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --no-cache]
Expand Down
4 changes: 2 additions & 2 deletions ci_scripts/doc-build-config/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

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

Expand Down Expand Up @@ -231,7 +231,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "%s.tex" % project, project, author, "manual"),
(master_doc, f"{project}.tex", project, author, "manual"),
]
numfig = True
highlight_language = "python"
Expand Down
4 changes: 2 additions & 2 deletions ci_scripts/doc-build-config/zh/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
templates_path = ["/templates"]

project = "PaddlePaddle"
author = "%s developers" % project
author = f"{project} developers"
copyright = "%d, %s" % (time.localtime(time.time()).tm_year, author)
github_doc_root = "https://github.com/PaddlePaddle/docs/docs"

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

# Use the .. admonition:: directive for Notes sections.
Expand Down
4 changes: 2 additions & 2 deletions docs/api/gen_alias_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def _find_real_api_by_grep_file(self, api_list):

obj = eval(api)
if inspect.isclass(obj):
reg = "class %s(" % api.split(".")[-1]
reg = "class {}(".format(api.split(".")[-1])
elif inspect.isfunction(obj):
reg = "def %s(" % api.split(".")[-1]
reg = "def {}(".format(api.split(".")[-1])

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

Expand Down
1 change: 0 additions & 1 deletion docs/dev_guides/code_contributing_path_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ Tabs remover (C++)...................................(no files to check)Skipped
Tabs remover (Python)....................................................Passed
copyright_checker........................................................Passed
black....................................................................Passed
flake8...................................................................Passed
ruff.....................................................................Passed
clang-format.........................................(no files to check)Skipped
cpplint..............................................(no files to check)Skipped
Expand Down
8 changes: 3 additions & 5 deletions docs/dev_guides/docs_contributing_guides_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,9 @@ fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
CRLF end-lines remover...................................................Passed
Tabs remover.............................................................Passed
CN-[whitespace]-EN fixer.................................................Passed
convert jinja2 into html.............................(no files to check)Skipped
convert-markdown-into-html...........................(no files to check)Skipped
black................................................(no files to check)Skipped
ruff.................................................(no files to check)Skipped
CN-[whitespace]-EN fixer.............................(no files to check)Skipped
ruff.....................................................................Passed
ruff-format..............................................................Passed
[my-cool-stuff ee8f4441f] fix docs bugs
1 file changed, 19 insertions(+), 34 deletions(-)
```
Expand Down
3 changes: 1 addition & 2 deletions docs/dev_guides/git_guides/codestyle_check_guide_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Tabs remover (C++).......................................................Passed
Tabs remover (Python)................................(no files to check)Skipped
copyright_checker........................................................Passed
black................................................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
ruff.................................................(no files to check)Skipped
clang-format.............................................................Failed
- hook id: clang-format
Expand Down Expand Up @@ -85,7 +84,7 @@ Date: xxx
| [Lucas-C/pre-commit-hooks](https://github.com/Lucas-C/pre-commit-hooks.git) | 社区维护的一些通用的 hook,含将 CRLF 改为 LF、移除 Tab 等 hook | 1.5.1 |
| [copyright_checker](https://github.com/PaddlePaddle/Paddle/blob/develop/tools/codestyle/copyright.hook) | Copyright 检查 | 本地脚本 |
| [black](https://github.com/psf/black) | Python 代码格式化 | 23.3.0 |
| [ruff](https://github.com/astral-sh/ruff) | Python 代码风格检查 | 0.3.5 |
| [ruff](https://github.com/astral-sh/ruff) | Python 代码风格检查 | 0.5.0 |
| [clang-format](https://github.com/llvm/llvm-project/tree/main/clang/tools/clang-format) | C++ 代码格式化 | 13.0.0 |
| [cpplint](https://github.com/cpplint/cpplint) | C++ 代码风格检查 | 1.6.0 |
| [clang-tidy](https://github.com/llvm/llvm-project/tree/main/clang-tools-extra/clang-tidy) | C++ 代码风格检查 | 15.0.2.1 |
Expand Down
12 changes: 10 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ select = [
# Pyupgrade
"UP",

# Flake8-pyi
"PYI",

# NumPy-specific rules
"NPY001",
"NPY003",
Expand Down Expand Up @@ -52,19 +55,24 @@ select = [

# Pylint
"PLE",
"PLC0414",
"PLC3002",
"PLR0206",
"PLR0402",
"PLR1701",
"PLR1711",
"PLR1722",
"PLW3301",

# Flake8-simplify
"SIM101",

# Pygrep-hooks
"PGH004",

# Flake8-type-checking
"TCH",

# Ruff-specific rules
"RUF010",
"RUF100",
]
unfixable = [
Expand Down

0 comments on commit dce5c33

Please sign in to comment.