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

Replace flake8 and move isort on Python files to ruff #78

Merged
merged 1 commit into from
May 1, 2023
Merged

Replace flake8 and move isort on Python files to ruff #78

merged 1 commit into from
May 1, 2023

Conversation

flpm
Copy link
Member

@flpm flpm commented Apr 25, 2023

Issue number of the reported bug or feature request: #45

Describe your changes

  • Removed pre-commit check for flake8
  • Removed setup.cfg (flake8 config)
  • Added a pre-commit check for ruff that cover flake8 checks and isort for Python files
  • Prevented isort pre-commit check from running on Python files

Testing performed

  • Verified that ruff is fixing import order in .py and .pyi files (tested by introducing wrong order)
  • Verified that ruff is fixing flake8 rules (tested by introducing unused import)

Additional context
Some isort options are not supported by ruff.

Option multi_line_output = 3 (break multiple imports in multiple lines using parenthesis) is not supported by ruff. The default behavior is the same as multi_line_output = 7 (all imports in one line without breaks), which used along force-single-line = true causes the multiple import to be split into individual imports. For example:

from collections import Counter, defaultdict, deque

is reformatted to:

from collections import Counter
from collections import defaultdict
from collections import deque

Options include_trailing_comma = true and force_grid_wrap = 0 are related to multi_line_output = 3 and are not applicable in ruff.

Option use_parentheses = true is also not supported by ruff, but because imports are in individual lines and line-length = 95, removing it would be very unlikely to cause problems.

Some references:
Use Parentheses in isort documnentation
Multi Line Output Modes in isort documentation
Flake 8 rules
Ruff rules

@godlygeek
Copy link
Contributor

godlygeek commented Apr 25, 2023

@flpm Thank you! Would you mind editing your commit messages to add the DCO signoff?

From the state your PR is in now, you can run:

git commit --amend -s -m "ci: Use ruff to lint Python files"
git push -f

to add a DCO signoff added to your most recent commit and then force-push it back to the PR.

@flpm
Copy link
Member Author

flpm commented Apr 28, 2023

After PR #77 is merged I will rebase and fix the code, I will make sure all the commits have the DCO signoff 👍

@godlygeek
Copy link
Contributor

I've merged #77 so you should now be unblocked, @flpm!

Signed-off-by: Felipe Moreno <felipe@flpm.dev>
Copy link
Contributor

@godlygeek godlygeek left a comment

Choose a reason for hiding this comment

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

LGTM

@godlygeek
Copy link
Contributor

Thanks for seeing this through, @flpm!

@godlygeek godlygeek merged commit 5c6f07c into bloomberg:main May 1, 2023
@flpm flpm deleted the ruff_pre-commit branch May 2, 2023 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants