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] Bump ruff to 0.3.0, remove flake8 and enable RUF100 #62782

Merged
merged 2 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions .flake8

This file was deleted.

7 changes: 1 addition & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,8 @@ repos:
hooks:
- id: black
files: (.*\.(py|pyi|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args: ["--config=.flake8"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.3.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --no-cache]
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ select = [

# Pygrep-hooks
"PGH004",

# Ruff-specific rules
"RUF100",
]
unfixable = [
"NPY001"
Expand Down Expand Up @@ -112,14 +115,11 @@ combine-as-imports = true
known-first-party = ["paddle"]

[tool.ruff.lint.per-file-ignores]
# These files need tabs for testing.
"test/dygraph_to_static/test_error.py" = ["E101", "W191"]
# Ignore compare with True in sot unittest
"test/sot/test_dup_top.py" = ["E712"]
# Ignore undefined variables in CMake config and some dygraph_to_static tests
".cmake-format.py" = ["F821"]
"test/dygraph_to_static/test_closure_analysis.py" = ["F821"]
"python/paddle/static/amp/decorator.py" = ["F821"]
# Ignore version check in setup.py
"setup.py" = ["UP036"]
# Ignore unnecessary comprehension in dy2st unittest test_loop
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

import paddle.distributed.fleet
import paddle.text
import paddle.vision # noqa: F401
import paddle.vision
from paddle import ( # noqa: F401
amp,
audio,
Expand Down
4 changes: 1 addition & 3 deletions python/paddle/distributed/auto_parallel/static/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ def build_program(self, mode):

# NOTE(dev): Because @to_static is a Lazy mechanism, so we explicitly call this to trigger
# generating Program IR immediately.
concrete_program = getattr(
self.proxy_layer, func_name
).concrete_program # noqa: B018
concrete_program = getattr(self.proxy_layer, func_name).concrete_program

# TODO(zhiqiu): prepare_op_amp_options is not supported for PIR program
# It will to use dynamic-static unified amp in pir program, and there is
Expand Down
8 changes: 1 addition & 7 deletions tools/check_file_diff_approvals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ fi
HAS_MODIFIED_PIR_INCLUDE_DIR=`git diff --name-only upstream/$BRANCH | grep "paddle/pir/include" || true`
if [ "${HAS_MODIFIED_PIR_INCLUDE_DIR}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then
echo_line="You must have one RD (yuanlehome, winter-wang, zhangbo9674) approval for file changes in paddle/pir/include.\n"
check_approval 1 yuanlehome winter-wang zhangbo9674
check_approval 1 yuanlehome winter-wang zhangbo9674
fi

HAS_MODIFIED_API_GENE=`git diff --name-only upstream/$BRANCH | grep "paddle/phi/api/yaml/generator" || true`
Expand Down Expand Up @@ -440,12 +440,6 @@ if [ "${INVALID_UNITTEST_ASSERT_CHECK}" != "" ] && [ "${GIT_PR_ID}" != "" ]; the
check_approval 1 qili93 luotao1 Aurelius84
fi

DEPRECATED_FLAKE8=`git diff --name-only upstream/$BRANCH | grep ".flake8" || true`
if [ "${DEPRECATED_FLAKE8}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then
echo_line="You must have one SigureMo or gouzil approval for file changes in .flake8, we are planned to replace Flake8 with Ruff in the future.\n"
check_approval 1 SigureMo gouzil
fi

TEST_FILE_ADDED_LINES=$(git diff -U0 upstream/$BRANCH -- test |grep "^+")
ENABLE_TO_STATIC_CHECK=`echo "$TEST_FILE_ADDED_LINES" | grep "enable_to_static(" || true`
if [ "${ENABLE_TO_STATIC_CHECK}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then
Expand Down