Ruff v0.16.0 – Significant new updates – 413 default rules up from 59

astral.sh

326 points by vismit2000 12 hours ago


nickjj - 9 hours ago

I updated a ~3k line Python project with this the other day. I was using v0.15.x beforehand. It didn't take too long and the new rules do improve code quality. It caught quite a few things previous versions didn't.

Here's a few commits of changes:

(A whole bunch of manual changes based on its suggestions) https://github.com/nickjj/plutus/commit/9af66d31f98bef841588...

(Re-enable line length) https://github.com/nickjj/plutus/commit/21789f89bbcee37913c1...

(Force _ prefix for unused variables) https://github.com/nickjj/plutus/commit/a272c77b932e1c78558a...

(Auto-corrected by Ruff) https://github.com/nickjj/plutus/commit/6fe69cf88385ebdf9b8c...

woadwarrior01 - 11 hours ago

Great to see ruff, ty and uv being actively developed, even after Astral was acquired by OpenAI.

maratc - 10 hours ago

The amount of fascination that people have with these "grammar nazi" bots -- some of them implementing completely arbitrary "rules" and some of them disagreeing with others on what "good" Python code should look like -- doesn't stop to amaze me.

Here's "bad" code:

     important_numbers = {
        'x': 3,
        'y': 42, # Answer to the Ultimate Question!
        'z': 2
    }
Here's what "good" code should look like:

    important_numbers = {"x": 3, "y": 42, "z": 2}  # Answer to the Ultimate Question!
Which completely misses the writer's intent. But did you notice that there are two spaces before the pound now? Also, the quotes are now double because apparently it's somehow more kosher! So much improvement!

The actual problems in the code I work with are not the spaces at the end of line or imports in non-alphabetic order, it's the 10-line list comprehensions that are so long that they're impossible for me to parse. None of these tools catch that. My place used pylint, flake8, black, ruff -- with hundreds of commits on every change. All that energy could be better spent elsewhere.