← Back to context

Comment by jon-wood

1 day ago

I 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.

I 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.

> 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"

If you want to be protected from changes in the default set, you can choose the ones you want with `select`.