Re:Ruff: A Fast Python Linter
by iwebdevfromhome on Tuesday June 06, 2023 @03:47PM
(#36218159)
interesting! I just set it up for a new project but I didn't know it had the ability to sort imports, how to you run this command ?
Enable the "I" category and run ruff with autofixing.
Re:Ruff: A Fast Python Linter
by anderskaseorg on Tuesday June 06, 2023 @04:00PM
(#36218341)
Ruff actually focuses on checks that don’t overlap with Black. (“By default, Ruff enables Flake8's E and F rules. Ruff supports all rules from the F category, and a subset of the E category, omitting those stylistic rules made obsolete by the use of an autoformatter, like Black.”)
Its import sorting is designed to be compatible with isort --profile=black by default (https://beta.ruff.rs/docs/faq/#how-does-ruffs-import-sorting...). Many isort settings are supported (https://beta.ruff.rs/docs/settings/#isort). I’m not sure what “fly to top” means.
Why not replace pylint with it?
Pylint has hundreds of rules that ruff doesn't have, yet; see this GitHub issue: https://github.com/charliermarsh/ruff/issues/689
It's not going to replace pylint, but pylint is hard to configure and slow.
There is overlap between ruff checks and what's eliminated by black though, since ruff implemented flake8 rules first and a lot of them are PEP8 oriented.
Also, note that ruff is also a fast import sorter, faster than isort. But it's not a 1:1 match to isort (no fly to top, some formatting are different).
All in all, I would advice to use it if you are not used to linters, or if you don't feel like going full bazooka on a project.
It's has a very good cost/benefit ratio give how lighweight and easy to use it is.