-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
MNT black → ruff format #31015
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 black → ruff format #31015
Conversation
❌ Linting issuesThis PR is introducing linting issues. Here's a summary of the issues. Note that you can avoid having linting issues by enabling You can see the details of the linting issues under the
|
40e80b0
to
a04d7be
Compare
b87f48e
to
63e9224
Compare
e2d9310
to
f6d2b41
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.
I'm mostly okay with this. We need to check what the difference is now between the --preview
mode of black
and ruff
, especially on long string lines, which black
was mostly handling nicely.
cc @scikit-learn/core-devs
This reduces our developer dependencies by one, which is nice.
f392787
to
59c2917
Compare
Rebased to solve conflicts. Please consider merging #30976, first to update ruff, so that we start with a recent and more stable version of the formatter. |
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.
Otherwise LGTM.
build_tools/linting.sh
Outdated
@@ -10,26 +10,25 @@ set -o pipefail | |||
|
|||
global_status=0 | |||
|
|||
echo -e "### Running black ###\n" | |||
black --check --diff . | |||
echo -e "### Running ruff check ###\n" |
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.
these messages must be identical to what's in the get_comment.py
for it to find the right section.
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.
linting.sh
and get_comment.py
should be in sync now.
59c2917
to
02c2108
Compare
|
907d6d5
to
fd4b36f
Compare
The linter / lint error is because CI runs the previous version of
scikit-learn/.github/workflows/lint.yml Lines 32 to 35 in f4ba17b
|
Not sure about the linter / comment error:
|
fd4b36f
to
b7d8201
Compare
I think the linter / comment error is a result of the linter / lint error and the lack of a scikit-learn/.github/workflows/lint.yml Lines 54 to 61 in f4ba17b
|
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.
There's one "comma" issue left, and I think you've forgotten to push your fixes for the other ones?
Otherwise, I'm happy to merge this and see if it works on main
since that's where the bot gets its data.
b7d8201
to
a077de8
Compare
Rebased and fixed the spurious commas. |
Please avoid force pushing. It makes reviews much harder since I can't check what's changed. We don't care about number of commits in a PR. Everything's squashed and merged anyway. |
Although long string handling is nice with |
I'm not sure which part of
It's true that |
Yup, I'm referring to the "Improve string processing" in black. For this PR, if it means removing another tool, I'm happy with not having it. |
Sorry I didn't get to merge this in time, @DimitriPapadopoulos would you mind fixing the merge conflicts? |
I will:
|
Additionally, although it doesn't matter here, run the linter first, then the formatter, as suggested by the documentation: Ruff's formatter is designed to be used alongside the linter. However, the linter includes some rules that, when enabled, can cause conflicts with the formatter, leading to unexpected behavior. When configured appropriately, the goal of Ruff's formatter-linter compatibility is such that running the formatter should never introduce new lint errors.
From the ruff documentation: By default, Ruff enables Flake8's `F` rules, along with a subset of the `E` rules, omitting any stylistic rules that overlap with the use of a formatter, like `ruff format` or Black. Therefore let ruff select the default ruleset, to avoid `E` rules that overlap with the formatter. Only document additional rules.
I001 Import block is un-sorted or un-formatted
They would be interpreted as a tuple by `ruff format`.
a077de8
to
d3bfa00
Compare
It would be great if this could be merged before new conflicts appear. |
2 approvals already let's merge this and see what happens (probably many PRs will have conflicts but 😅). The linter GHA is red but this is expected because the bot comment thingy is partly driven by |
* Enforce ruff rules (RUF) (scikit-learn#30694) * Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695) * black → ruff format (scikit-learn#31015)
* Enforce ruff rules (RUF) (scikit-learn#30694) * Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695) * black → ruff format (scikit-learn#31015)
* Enforce ruff rules (RUF) (scikit-learn#30694) * Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695) * black → ruff format (scikit-learn#31015)
Introduced by this commit in scikit-learn#31015: 620b0de MNT black → ruff format
* Enforce ruff rules (RUF) (scikit-learn#30694) * Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695) * black → ruff format (scikit-learn#31015)
Reference Issues/PRs
See #30695 (comment).
What does this implement/fix? Explain your changes.
black .
→ruff format
Any other comments?
Not sure how to get this past CI tests in a single move.
This PR change
black
toruff format
, but CI tests still useblack
.