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

MNT replace flake8 with ruff #26630

Merged
merged 5 commits into from
Jun 20, 2023
Merged

MNT replace flake8 with ruff #26630

merged 5 commits into from
Jun 20, 2023

Conversation

adrinjalali
Copy link
Member

This replaces flake8 with ruff (https://github.com/astral-sh/ruff), which is significantly faster than flake8, and can also fix many of the reported issues automatically (in pre-commit hooks).

Once this is merged, we can then introduce import sorting (instead of using isort) through ruff as well (and more linting).

cc @thomasjpfan @ogrisel

@github-actions
Copy link

github-actions bot commented Jun 20, 2023

Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

@adrinjalali
Copy link
Member Author

ruff is not available here in the linter since it's a pull_request_target and is using the version from main.

@ogrisel
Copy link
Member

ogrisel commented Jun 20, 2023

Run ./build_tools/linting.sh &> /tmp/linting_output.txt
  ./build_tools/linting.sh &> /tmp/linting_output.txt
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.11.4/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib
Error: Process completed with exit code 1.

but the linter bot comment is still sunny.

@ogrisel
Copy link
Member

ogrisel commented Jun 20, 2023

I tried the pre-commit hook locally and it's green:

$ pre-commit run ruff -a
ruff.....................................................................Passed

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM, lets merge it and see if it works.

@ogrisel
Copy link
Member

ogrisel commented Jun 20, 2023

Maybe the linter should do something like:

./build_tools/linting.sh 2>&1 | tee /tmp/linting_output.txt

so that we can access the raw output of the linting.sh script in the logs of the CI when the bot does not pick it up for some reason?

@adrinjalali
Copy link
Member Author

@ogrisel the next step (comment) already prints the log, so you can see that there.

The failure in the linter is really not supposed to happen in usually though. This is very specific to this PR (or changing linting tools / dependencies) which we do very rarely.

@ogrisel
Copy link
Member

ogrisel commented Jun 20, 2023

@ogrisel the next step (comment) already prints the log, so you can see that there.

Yes I found out, after commenting:

https://github.com/scikit-learn/scikit-learn/actions/runs/5322327168/jobs/9638664632#step:6:16

What @thomasjpfan implies above is that 6188b36 will only have an effect once this PR is merged because it's a change in the workflow file? If so, +1 for merge.

@adrinjalali adrinjalali enabled auto-merge (squash) June 20, 2023 13:40
@adrinjalali adrinjalali merged commit 23a0dcb into scikit-learn:main Jun 20, 2023
@adrinjalali adrinjalali deleted the ruff branch June 20, 2023 15:10
@lucyleeow
Copy link
Member

lucyleeow commented Jun 21, 2023

Note, I think this is causing CI runs more recent than this PR (?) that have not rebased with main to fail 'linter / lint (pull_request_target)' with error:

### Running flake8 ###

./build_tools/linting.sh: line 26: flake8: command not found
Problems detected by flake8, please fix them

Though confusingly github actions bot tells you that 'Linting Passed'. Solved by rebasing with main.
see: #26643, #26641

cc @adrinjalali

@adrinjalali
Copy link
Member Author

@lucyleeow #26638 should fix the issue.

@lorentzenchr
Copy link
Member

@adrinjalali Thanks for pushing ruff!

jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Jun 29, 2023
jeremiedbb pushed a commit that referenced this pull request Jun 29, 2023
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants