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 isort, black and flake8 with ruff #617

Merged

Conversation

einarwar
Copy link
Contributor

@einarwar einarwar commented Aug 1, 2024

Ruff has emerged as the most popular tool for linting, and covers the rules from flake8 among others. It also serves as an (almost) drop in replacement for black and isort.

This PR replaces flake8, isort and black with ruff.

  • There are some minor differences is how black and ruff formats the files, as seen in the files formatted in this PR
  • Ruff with F, E and W covers the rules by the existing flake8 according to these docs
  • Updated pre-commit and github actions to also use Ruff

@LewisGaul
Copy link
Collaborator

Ruff has emerged as the most popular tool for linting, and covers the rules from flake8 among others. It also serves as an (almost) drop in replacement for black and isort.

Ruff is great, especially for linting. I have a slight concern about switching over from black/isort given the [minor] differences, meaning that IDEs then need to be reconfigured to not use black/isort and use ruff instead, and I'm not sure ruff is currently used more widely than black for formatting. Otherwise I'm in favour, with the biggest win being ruff check --fix.

@einarwar
Copy link
Contributor Author

einarwar commented Aug 5, 2024

I have a slight concern about switching over from black/isort given the [minor] differences, meaning that IDEs then need to be reconfigured to not use black/isort and use ruff instead, and I'm not sure ruff is currently used more widely than black for formatting.

Yeah ruff format is pretty new, and i think Black is most widely used as a formatter. While i personally think that the best way is to let the formatting, isort and lint settings be defined in pyproject.toml and let the IDE and possible extensions get settings from that file, i can respect that this is not how everyone has set up their development.

I can revert to still using black for formatting. It does not seem like there is any changes related to ruff isort compared to "normal" isort, so tempted to keep that to reduce the number of dependencies if that is okay :)

@gabrieldemarmiesse
Copy link
Owner

I'm in favor of using ruff for everything (isort, flake8, and black replacement). While it is true that it is not as used as black and isort, there is a big win in developer experience. For those who don't wish to use the pre-commit for example. It's true that people will have to change the formatting in their IDE for those who use it, but if the pre-commit is installed anyway, the formatting will be fixed before commiting. It was long overdue that the Python ecosystem get a rust-like developer experience with tooling.

A question I have. Will ruff check --fix run in the pre-commit? That would be great for the DX

@einarwar
Copy link
Contributor Author

einarwar commented Aug 5, 2024

A question I have. Will ruff check --fix run in the pre-commit? That would be great for the DX

I think so. Will update :)

@gabrieldemarmiesse
Copy link
Owner

Thanks! Great PR by the way :)

Copy link
Owner

@gabrieldemarmiesse gabrieldemarmiesse left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@gabrieldemarmiesse gabrieldemarmiesse merged commit 9874b40 into gabrieldemarmiesse:master Aug 5, 2024
38 checks passed
@einarwar einarwar deleted the add-ruff-isort-black branch August 5, 2024 14:00
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