News for hackers. Stuff that matters.
Re:Ruff: A Fast Python Linter by samwillis on Tuesday June 06, 2023 @03:12PM (#36217675)
Re:Ruff: A Fast Python Linter by dang on Tuesday June 06, 2023 @05:28PM (#36219341)
Thanks! Macroexpanded:

Ruff: A fast Python linter, written in Rust - https://news.ycombinator.com/item?id=34788020 - Feb 2023 (67 comments)

Ruff – a fast Python Linter written in Rust - https://news.ycombinator.com/item?id=32666035 - Aug 2022 (46 comments)

Reposts are ok when a story hasn't had significant attention in the last year or so (https://news.ycombinator.com/newsfaq.html) but as both of those threads were within the last year, the current submission counts as a dupe.

The intention behind that rule is to have a balance: it's good to re-discuss popular topics from time to time, and we also want room on the front page for lots of uncorrelated and unfamiliar things.

Re:Ruff: A Fast Python Linter by BiteCode_dev on Tuesday June 06, 2023 @03:36PM (#36218012)
Ruff is an excellent base linter because it takes care of essential stuff and has sane default while integrates well without much work.

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.

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 ?
Re:Ruff: A Fast Python Linter by claytonjy on Tuesday June 06, 2023 @04:21PM (#36218595)
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.

Re:Ruff: A Fast Python Linter by jstx1 on Tuesday June 06, 2023 @04:11PM (#36218480)
Why not replace pylint with it?
Re:Ruff: A Fast Python Linter by claytonjy on Tuesday June 06, 2023 @04:20PM (#36218584)
Pylint has hundreds of rules that ruff doesn't have, yet; see this GitHub issue: https://github.com/charliermarsh/ruff/issues/689
Re:Ruff: A Fast Python Linter by ihaveajob on Tuesday June 06, 2023 @04:02PM (#36218381)
I'm very happy with ruff after coming from using flake8. I have it integrated in my pre-commit scripts, and it catches a lot of small stuff that would cause trouble down the pipeline. Best of all, it's really fast, as advertised, so it's much more practical than flake8 for that. All said, I'd still add heavier linters to a CI/CD process.
Re:Ruff: A Fast Python Linter by renewiltord on Tuesday June 06, 2023 @04:08PM (#36218436)
Neat, it has a PyCharm plugin. Thanks, gonna try it out.

https://plugins.jetbrains.com/plugin/20574-ruff

Re:Ruff: A Fast Python Linter by maleldil on Tuesday June 06, 2023 @04:59PM (#36219039)
Ruff is amazing. I recommend turning on the [I]import rules as a replacement of isort and running `ruff check --fix`. Run it with black for best results.

It also has a very good LSP that complements pyright in my neovim setup. There's also a plug-in for pylsp if you're using an editor that doesn't support multiple LSPs at the same time (e.g. Helix).

After that, check the rules page[0] for anything that might be relevant to your project. Between enabling some of these rules, using pyright, black and sourcery, I feel like the most relevant cases are covered.

[0] https://beta.ruff.rs/docs/rules/