Summary -- This PR updates our ruff-pre-commit dependency to 0.16.5, which supports the new category selectors, and then enables `lint.preview` and the new default categories so that we can dogfood them on our code. There were 66 diagnostics initially, which I also fixed or ignored: ``` 28 FURB113 [ ] repeated-append 12 ASYNC240 [ ] blocking-path-method-in-async-function 6 RUF105 [*] noqa-comments 5 PLW1510 [ ] subprocess-run-without-check 3 PLW0108 [ ] unnecessary-lambda 2 EXE001 [ ] shebang-not-executable 2 RUF039 [*] unraw-re-pattern 1 B024 [ ] abstract-base-class-without-abstract-method 1 FURB142 [*] for-loop-set-mutations 1 PERF102 [ ] incorrect-dict-iterator 1 PLC0207 [*] missing-maxsplit-arg 1 PLW0127 [ ] self-assigning-variable 1 TRY004 [ ] type-check-without-type-error 1 PLW0120 [*] useless-else-on-loop 1 TRY201 [ ] verbose-raise ``` Of these, I ignored `repeated-append` and `blocking-path-method-in-async-function`. I think they are still reasonable defaults, just less useful/important in our uses. 0.16.5 also includes https://github.com/astral-sh/ruff-pre-commit/pull/159, so I removed `markdown` from our main `ruff-format` hook, leaving it for the later mdtest formatting stage. I also had to make a few changes related to config discovery in tests: - move our cached ecosystem checkouts to `$RUNNER_TEMP` instead of inside of our checkout - convert some CLI tests to use the `CliTest` helpers - add `configurationPreference: editorOnly` to some notebook tests In these cases, our own Ruff settings were being inherited by test code. This likely affects many other tests, but I only updated the obviously failing ones for now. I'm least confident about the notebook tests, but as far as I can tell from the history (https://github.com/astral-sh/ruff/pull/11944, https://github.com/astral-sh/ruff/pull/22810), the specific diagnostics are not the important parts being asserted. Test Plan -- CI on this PR
ruff-ecosystem
Compare lint and format results for two different ruff versions (e.g. main and a PR) on real world projects.
Installation
From the Ruff project root, install with uv:
uv tool install -e ./python/ruff-ecosystem
Usage
ruff-ecosystem <check | format> <baseline executable> <comparison executable>
Note executable paths may be absolute, relative to the current working directory, or will be looked up in the current Python environment and PATH.
Run ruff check ecosystem checks comparing your debug build to your system Ruff:
ruff-ecosystem check ruff "./target/debug/ruff"
Run ruff format ecosystem checks comparing your debug build to your system Ruff:
ruff-ecosystem format ruff "./target/debug/ruff"
Run ruff format ecosystem checks comparing with changes to code that is already formatted:
ruff-ecosystem format ruff "./target/debug/ruff" --format-comparison ruff-then-ruff
Run ruff format ecosystem checks comparing with the Black formatter:
ruff-ecosystem format black ruff -v --cache python/checkouts --format-comparison black-and-ruff
The default output format is markdown, which includes nice summaries of the changes. You can use --output-format json to display the raw data — this is
particularly useful when making changes to the ecosystem checks.
Development
When developing, it can be useful to set the --pdb flag to drop into a debugger on failure:
ruff-ecosystem check ruff "./target/debug/ruff" --pdb
You can also provide a path to cache checkouts to speed up repeated runs:
ruff-ecosystem check ruff "./target/debug/ruff" --cache ./repos