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 isort #366

Merged
merged 1 commit into from
Apr 25, 2023
Merged

Conversation

flpm
Copy link
Member

@flpm flpm commented Apr 24, 2023

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

Describe your changes

  • Removed pre-commit check for flake8
  • Removed setup.cfg (flake8 config)
  • Added a pre-commit check for ruff that covers flake8 checks and isort for Python files (.py and .pyi)
  • 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, 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

@flpm flpm force-pushed the replace_flake8_and_isort branch 2 times, most recently from e52451b to 540fa2f Compare April 25, 2023 16:40
Rather than running `flake8` and `isort` on Python files, use `ruff`.

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 godlygeek enabled auto-merge (rebase) April 25, 2023 21:28
@godlygeek godlygeek merged commit 279ac76 into bloomberg:main Apr 25, 2023
24 of 25 checks passed
@flpm flpm deleted the replace_flake8_and_isort 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.

None yet

2 participants