mirror of
https://github.com/astral-sh/ruff.git
synced 2026-10-28 10:45:37 +08:00
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