-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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] [python-package] use ruff, enforce flake8-bugbear and flake8-comprehensions checks #5871
Conversation
Have you seen ruff? I remember one of the reasons to adopt it was that it's a single dependency that has many linters, for example I see these two in there. What do you think of using that instead? |
Sure let's try it! We can use this PR to test that out, I'll push some changes later. |
@jmoralez I tried Great suggestion 🤩 It's ridiculously fast and really easy to configure, following these docs: I just pushed some commits that propose using I chose NOT to have it run |
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.
LGTM. Just a suggestion but it's fine to leave it out of this.
This pull request has been automatically locked since there has not been any recent activity since it was closed. |
Proposes using
ruff
(https://github.com/charliermarsh/ruff) in this project'slint
task, to enforce the following checks:flake8
(pyflakes
+pycodestyle
)flake8-bugbear
flake8-comprehensions
pydocstyle
Proposes enabling the following
flake8
plugins (viaruff
):flake8-bugbear
(https://github.com/PyCQA/flake8-bugbear)flake8-comprehensions
(https://github.com/adamchainz/flake8-comprehensions)This PR also fixes the following types of issues found by
flake8-bugbear
...... and these found by
flake8-comprehensions
full logs (click me)
Benefits of these changes
ruff
...flake8
and a ton of other checks (see the list under "Rules" at https://pypi.org/project/ruff/)flake8
These two new
flake8
plugins...... reduce variability in code style across the project's Python code.
... for some cases, very very very slightly improve efficiency. For example, using a set literal (
{}
) is a bit more efficient than constructing a list, creating a set from it, and immediately throwing away that list.... push into automation something that previously required maintainer effort in pull requests... preventing the use of mutable data structures as function argument defaults.
Notes for Reviewers
I originally opened this PR just trying to add
flake8-bugbear
andflake8-comprehensions
, but then switched it to addingruff
based on @jmoralez 's recommendation in #5871 (comment).