-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
[CI][Linter] Replace flake8
and isort
with ruff
#49435
base: master
Are you sure you want to change the base?
[CI][Linter] Replace flake8
and isort
with ruff
#49435
Conversation
18e5b64
to
18ead33
Compare
flake8
and isort
with ruff
3474ec9
to
aab7d03
Compare
Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
aab7d03
to
2e84c6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blazing fast linting ⚡️
df361dc
to
e2ae29c
Compare
Needs Ray Data, RLLib approval, @sven1977 @bveeramani |
e2ae29c
to
7a5cd1a
Compare
Closes: ray-project#48508 Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Closes: ray-project#48508 Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Closes: ray-project#48508 Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Closes: ray-project#48508 Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Closes: ray-project#48508 Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Closes: ray-project#48508 Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Closes: ray-project#48508 Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Closes: ray-project#48508 Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
7a5cd1a
to
3e6224f
Compare
if [ $HAS_FLAKE8 ]; then | ||
echo "$(date)" "Flake8...." | ||
git ls-files -- '*.py' "${GIT_LS_EXCLUDES[@]}" | xargs -P 5 \ | ||
flake8 --config=.flake8 | ||
|
||
git ls-files -- '*.pyx' '*.pxd' '*.pxi' "${GIT_LS_EXCLUDES[@]}" | xargs -P 5 \ | ||
flake8 --config=.flake8 "$FLAKE8_PYX_IGNORES" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to replace this with ruff
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment here #49435 (comment). These comments were folded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about *.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the Ruff pre-commit hook to automatically locate the corresponding Python files. See
- https://github.com/ray-project/ray/pull/49435/files#diff-63a9c44a44acf85fea213a857769990937107cf072831e1a26808cfde9d096b9R34-R36
- https://github.com/astral-sh/ruff-pre-commit/blob/6299d2ca232741e7e33e7fd8a5a10059bd743da7/.pre-commit-hooks.yaml#L6
- https://github.com/ray-project/ray/pull/49435/files#diff-ad6658a2c0375932b4a9f18312962089115b0d5a0c817e84e0213cc78cbfe927R17-R18
for details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does CI run pre-commit hook or it only runs when people enabled pre-commit hook locally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wait until getting the approval from @aslonnie |
Why are these changes needed?
This PR replaces
flake8
andisort
withruff
.To minimize changes, all rules that cause file modifications are ignored.
Although this PR involves many files, the changes to Python files are limited to modifications of flake8 comments.
The latest version of
ruff
does not support disabling checks forSyntaxError
, sopython/ray/serve/tests/test_config_files/syntax_error.py
is explicitly excluded inpyproject.toml
. See https://docs.astral.sh/ruff/rules/syntax-error/ for details.The context of why to replace
flake8
withruff
is that while running the pre-commit hook of flake8, an error occurs if the Python version is 3.12. This is because the version of flake8 is too old. Then, @jjyao suggested that I replace it with ruff instead of upgrading flake8. See #47991 (comment) for details.Follow-up:
black
withruff format
#49436Related issue number
Closes #48508
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.