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

[ci] use Ruff linter instead of isort #6755

Merged
merged 29 commits into from
Dec 15, 2024
Merged

[ci] use Ruff linter instead of isort #6755

merged 29 commits into from
Dec 15, 2024

Conversation

StrikerRUS
Copy link
Collaborator

@StrikerRUS StrikerRUS commented Dec 15, 2024

Let Ruff work with imports sorting directly.
This change speeds up the pre-commit job, avoids situations where ruff and isort are fighting each other and allows to consistenly configure only one tool.

Refer to: https://docs.astral.sh/ruff/faq/#how-does-ruffs-import-sorting-compare-to-isort.

Also, bump versions of pre-commit libraries.

@@ -2507,13 +2507,13 @@ def _compare_params_for_warning(
compare_result : bool
Returns whether two dictionaries with params are equal.
"""
for k in other_params:
for k, v in other_params.items():
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fix PLC0206 in new Ruff version.

return False
for k in params:
for k, v in params.items():
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fix PLC0206 in new Ruff version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh wow, I'm impressed that a linter could look in this far and find something like this! Really nice.

@@ -154,6 +143,7 @@ select = [
"D",
# pycodestyle
"E",
"W",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"W",
# pycodestyle (warnings)
"W",

Sorry, missed this before I approved.

Could you:

  • add a comment like this one
  • change the comment over "E" # pycodestyle (errors)
  • keep this list alphabetically organized by rule code (so move this "W" to the end, and put isort after "F"

I think that makes it a bit easier to find the relevant entry in the config and map it to the type of check.

Very very minor suggestion, so if you disagree at all then just merge this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, will do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in 4cb519e. Is it OK now?

Comment on lines 159 to 160
# isort
"I",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Enable isort.

@@ -196,3 +188,6 @@ select = [

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.lint.isort]
known-first-party = ["lightgbm"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@StrikerRUS StrikerRUS marked this pull request as ready for review December 15, 2024 00:27
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

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

Really like this, thanks very much1

return False
for k in params:
for k, v in params.items():
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh wow, I'm impressed that a linter could look in this far and find something like this! Really nice.

@StrikerRUS StrikerRUS changed the title [ci] use Ruff linter instead of isort [WIP][ci] use Ruff linter instead of isort Dec 15, 2024
@StrikerRUS StrikerRUS changed the title [WIP][ci] use Ruff linter instead of isort [ci] use Ruff linter instead of isort Dec 15, 2024
@jameslamb jameslamb self-requested a review December 15, 2024 05:36
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

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

re-approving

@StrikerRUS StrikerRUS merged commit c2f3807 into master Dec 15, 2024
48 checks passed
@StrikerRUS StrikerRUS deleted the ci/linters branch December 15, 2024 13:09
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.

2 participants