9 ms·
Ruff v0.16.0 – Significant new updates – 413 default rules up from 59
- kstenerud 3mo agoThis is great news! With the advent of agentic coding, strong linting is more important than ever. What I'd really like to see is forbidigo for more languages.
- alentred 3mo ago100% agree, I am upgrading my projects now. And yet, I have mixed feelings about this. I like to think that when I (was) writing code myself, I applied a great deal of intuition to decide when to skip or ignore some rule. On the hand, I also saw projects were developers where using pylint with most rules enabled and I have to say the code was not better - on the contrary it had plenty of hacks to make pylint happy at the cost of illegible code. Not unlike that experience, I also saw coding agents spend lots of tokens trying to fix a benign issue, as well as doing the opposite - like disabling the tests !!! when they don't pass. :facepalm: I grew to trust AI results in terms of overall correctness, but I still have hard time trusting their *judgement* on the *code quality*.
- woadwarrior01 3mo agoGreat to see ruff, ty and uv being actively developed, even after Astral was acquired by OpenAI.
- appplication 3mo agoTbh I was super enthusiastic about Ty but it’s just so far behind basedpyright I had to switch off it. The lack of checks wasn’t the issue, it was the false positives which were the real dealbreaker. That and it doesn’t have support for baselining, which is such an insanely awesome feature for larger codebases. uv and ruff are incredible though. Maybe someday on Ty.
- hyeongjun 3mo agoGood news. enabling 413 rules by default means most projects get useful linting without touching the config at all!
- embedding-shape 3mo agoMaybe it's just me, but getting overrun with "413 x potential warnings" hardly sounds useful :) Great for greenfield, less so for existing projects. Although nowadays, fire up your agent with "/goal work through and address all lint warnings by fixing the code according to XYZ" and leave it alone for a couple of hours and I guess it's no longer an issue... Don't get me wrong, the new level of details coming from Ruff is much appreciated and a good thing :)
- biorach 3mo ago> uv run ruff check --fix Generally gets you 90% there.
- vasachi 3mo agoIn reality it got me 30% there.
- tclancy 3mo agoThat suggests it’s doing its job.
- embedding-shape 3mo agoI don't think they were trying to say "No, ruff doesn't work at all", more that "gets you 90% there" might have been an over-exaggeration, or very codebase-specific number and really, YMMV.
- apelapan 3mo agoOn the 0.16.0 release it was more like 10% autofixable on the codebases I maintain. One of them had 100+ unfixable errors across less than 10k lines of code and tests in total. Previous ruff version labeled it perfectly clean on format and check with default settings. Good thing we have LLM:s that can do the tedious work of checking each case and applying local annotations or updating the config globally! If I was stuck doing this manually, I would have just gotten rid of ruff and went back to black+pylint.
- bbor 3mo agoRuff v0.16 has a small number of breaking changes Why. Why must my poor semver be hurt so! I sorta kinda get why `ty` is pre v1.0.0 -- it's a typechecker that doesn't check a huge number of types. But what are we waiting for with `ruff`? Surely it's eaten whatever the old options were (black? maybe a few takes on py+lint?) by now many times over, and is even more dominant than `uv`. I run this program hundreds of times a day so I'm generally excited for new features, but I guess the OAI acquisition has made me ornery when it comes to these folks. Apologies to kindly nerds who made this release happen, and congrats <3
- colinmarc 3mo agoIt's conventional for semver to allow breaking changes for 0.x minor releases (but not for patch releases).
- jakobnissen 3mo agoYes but the question is why Ruff has not released v1 yet. They’re clearly used in production and the entire purpose of v0.x is to signal a project is early in development and is expected to have coarse edges.
- ameliaquining 3mo agoThe versioning doc linked elsewhere in the thread explains: There isn't yet a stable API and they want to wait on that before releasing v1.
- microtonal 3mo agoWhy must my poor semver be hurt so! It is fully according to their versioning policy: https://docs.astral.sh/ruff/versioning/ https://docs.astral.sh/ruff/versioning/ But also compliant with semver: Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable. https://semver.org/ https://semver.org/ (Maybe I misinterpreted your remark, but semver does not get hurt.)
- 3mo ago
- vanyaland 3mo agoran 0.16 on a file with no config, it flags unsorted imports and `except Exception` by default now
- anticodon 3mo agoYou know how many bugs I've met working on large Python codebases over 20 years, caused by unsorted imports or `except Exception`? Yeah, you've guessed it: exactly 0 bugs. It's really annoying how many people think that if you enforce stupidly strict rules about formatting, more strict that those of Fortran in 70s, you'll automatically get good code. I've seen companies that enable 100% of ruff rules, use several other linters, and enforce other rules (like every variable name should be at least 20 characters long to fully describe its purpose). And they have awful buggy unmaintainable code. But it is nicely formatted (although reading code where half of the screen estate is consumed by the variable name is a bit difficult) and has no "dreadful" `except Exception`. Or every mutable class attribute variable is annotated with `typing.ClassVar` (RUF012 - the most idiotic rule I've ever seen). Nevermind that it doesn't really stop anyone from changing value of that attribute. You must annotate it with `ClassVar`! It's an idiotic cargo-cult.
- BigTTYGothGF 3mo agoI think it should depend on if it's `except Exception` (don't use) or `except Exception as e` (probably fine, as long as you log `e` or do something else with it).
- IshKebab 3mo agoI don't think people expect import sorting to fix bugs. It's just good (and free!) practice. Anyway I have definitely had linters like Ruff catch bugs. Probably the most common is the mutable default argument gotcha.
- anticodon 3mo agoI'm not saying that it's not catching bugs. Sometimes it does. But most of the rules are nonsense and the number of rules that makes no sense is growing. Also, mutable default argument is not a bug. It is a bug only if mutable default argument is mutated inside the body of a function/method. Which is almost never the case.
- deleted 3mo ago[deleted]
- gempir 3mo agoI wish Go had something like Ruff! A lot of languages are getting amazing tool but Go has a very fragmented ecosystem with a lot of tools but none of them feel as high quality has the likes of Ruff, Oxc, Biome or even PHP's Mago
- brainzap 3mo ago[flagged]
- gempir 3mo agoI have actually tried. But I'm not very knowledgable in the area, so it's more LLM slop than my good ideas. And I'm not sure I have the energy and passion to maintain it long term. https://github.com/gempir/strider https://github.com/gempir/strider It's definitely possible, if Google would put like one or two smart minds on the problem full time they could easily solve this problem and make the ecosystem so much stronger. But I'm guessing they already have something like this in-house and no interest in open sourcing it.
- bargainbin 3mo agoI’m not entirely sure what you mean by a fragmented ecosystem? Go has first-party formatting and linting and the language is deliberately restricted to ensure it is written in a certain way, even when written by complete novices. Compare that to Python or TypeScript which are Wild West languages without opinionated first-party tooling, and it’s clear why Ruff/Biome feel great. You just wouldn’t get that same high with Go.
- maratc 3mo agoThe 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.
- jbvlkt 3mo agoThose tools actually save team energy. Without them any programmer has different opinion on formating, code quality, what is readable etc. You can discuss it endlesly or you can just use ruff.
- maratc 3mo agoWe can replace the endless and useless discussion on how to format code with an endless and useless discussion on what linting tool to use. Another option would be to leave both topics alone and go on with our lives, improving the product, fixing bugs, implementing new features, and generally giving customers a better product and shareholders more value, while respectfully agreeing to disagree on the issues of style.
- jbvlkt 3mo agoPeople tend to use tools set up in CICD and/or precommit. Without rules everyone uses their tool and is unwilling to compromise. Even if they are willing it is hard to setup tools to do exactly what you want. Default configuration is always the way.
- hackerbrother 3mo agoLooks like it's recommended to use zero-config now, which is great! My new .ruff.toml is just: line-length = 300
- deleted 3mo ago[deleted]
- luciana1u 3mo ago[flagged]
- assimpleaspossi 3mo agoI find it somehow interesting that a tool for Python is written in Rust.
- IshKebab 3mo agoIt's the same for JavaScript. Rust is the better language (especially for large projects like these), but sometimes you don't have a choice but to use Python or JS/TS.
- fn-mote 3mo agoInteresting but not surprising in an application where speed matters.
- Hamuko 3mo agoWait until you hear what CPython is written in.
- lijok 3mo agoWhat languages are python interpreters written in?
- nickjj 3mo agoI 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/9af66d31f98bef841588effe7e1288395d6f7bce https://github.com/nickjj/plutus/commit/9af66d31f98bef841588... (Re-enable line length) https://github.com/nickjj/plutus/commit/21789f89bbcee37913c13a98abf789a3f3b56341 https://github.com/nickjj/plutus/commit/21789f89bbcee37913c1... (Force _ prefix for unused variables) https://github.com/nickjj/plutus/commit/a272c77b932e1c78558a790bbff2a11517fc9d81 https://github.com/nickjj/plutus/commit/a272c77b932e1c78558a... (Auto-corrected by Ruff) https://github.com/nickjj/plutus/commit/6fe69cf88385ebdf9b8c2c63c3566e76ef8093f4 https://github.com/nickjj/plutus/commit/6fe69cf88385ebdf9b8c...
- Oliveaniss 3mo ago[dead]
- aomix 3mo agoIf you listen closely you can hear the thousands of CI jobs that just pull latest UV failing all at once.
- mikeydiamonds 3mo agoDefault on lint is good for agent fleets. fwiw, I watched one agent "fix" an unfamiliar rule by deleting the test; perfect compliance, tiny misunderstanding.
- blks 3mo agoEvery new single piece of software calls itself “extremely fast”, “blazingly fast”, it gets tiring.
- frumiousirc 3mo agoruff is not new. It's also truly really fast. On an as-yet un-ruff'ed 32k SLOC python package it returns in 158ms finding 2k errors. Having it fix errors is also very fast. What's really tiring is reading such facile "critiques", especially when they are not even applicable.
- blks 3mo agoI’m not claiming it’s not fast, I’m commenting on general trend in how many projects market themselves
- BigTTYGothGF 3mo agoCompare it to some of the other options in that space and you'll see why that was a selling point.
- cpburns2009 3mo agoBroadly you have a point. In this case I would expect a Rust-based Python linter to run significantly faster than one writen in Python itself (e.g., pylint).
- OoooooooO 3mo agoRuff is very fast.
- latent-9 3mo agothis is writing 3000 lines in this era you must be a normal human being
- dfasifsaf 3mo ago[flagged]
- jon-wood 3mo agoI really wish Ruff would introduce something similar to Nix’s stateVersion, which is used to determine the set of defaults that will be applied. Updating Ruff at a scale beyond a single repo is a bit of a crapshoot currently, with every version introducing a bunch of new default rules which you then have to deal with immediately (either by turning them off or fixing them). I’m aware we could have an allowlist in place which specifies all rules that are turned on but I’d much rather have a simpler config file, and be able to bump the state version at a good time for everyone to spend a few hours fixing new violations.
- mirashii 3mo agoI think the consensus is that this would be the wrong end to tackle the problem from. Your project should include ruff at the version it wants to use in its pyproject.toml. Bump the version when you're ready to spend the time on one project, but no need to coordinate across multiple projects. If you really want to do it, you can, but if there's one hold-out, you're not stuck behind forever because one project can't move yet.
- gcarvalho 3mo ago> with every version introducing a bunch of new default rules which you then have to deal with immediately According to the original post > Ruff's default rule set was last modified in v0.1.0 Which was over 2 years ago. https://github.com/astral-sh/ruff/releases/tag/v0.1.0 https://github.com/astral-sh/ruff/releases/tag/v0.1.0
- maleldil 3mo agoIf you want to be protected from changes in the default set, you can choose the ones you want with `select`.
- frumiousirc 3mo ago> I really wish Ruff would introduce something similar to Nix’s stateVersion Two approaches: You can pin the version of `ruff` in `pyproject.toml`. You, to let ruff command version advance but pin the settings to a prior version: uvx ruff@0.15.22 check --isolated --show-settings | flat2toml > pinned.toml The `flat2toml` script is left as an exercise. Then in `ruff.toml`: extend = "pinned.toml"
- jdsfijfdsifs 3mo ago[dead]
- westurner 3mo agoTIL RustPython uses Ruff's AST which is fast. LibCST can modify the AST/CST to do python codemod, now in Rust too; rustpython-ruff_python_parser: https://crates.io/crates/rustpython-ruff_python_parser https://crates.io/crates/rustpython-ruff_python_parser .. https://github.com/astral-sh/ruff https://github.com/astral-sh/ruff LibCST: https://github.com/Instagram/LibCST https://github.com/Instagram/LibCST