Skip to content

[ci] use Ruff linter instead of isort#6755

Merged
StrikerRUS merged 29 commits intomasterfrom
ci/linters
Dec 15, 2024
Merged

[ci] use Ruff linter instead of isort#6755
StrikerRUS merged 29 commits intomasterfrom
ci/linters

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.

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.

if k not in params or params[k] != v:
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.

"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.

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

if k not in params or params[k] != v:
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
@StrikerRUS StrikerRUS deleted the ci/linters branch December 15, 2024 13:09
@github-actions
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity since it was closed.
To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants