Upgrade ruff to 0.16.0#92
Draft
davegaeddert wants to merge 1 commit into
Draft
Conversation
Ruff 0.16 changes two defaults that plain.code inherits, and since `ruff_defaults.toml` ships to every Plain project, both would have reached users through a transitive ruff resolve without them changing anything. Pin the rule set explicitly. Ruff grew its built-in default selection from 59 rules to 413, and `ruff_defaults.toml` used `extend-select`, which layers on top of that default — `plain code check` went from 155 rules to 445, firing 1474 errors across this repo. Spelling out the old base (`E4`, `E7`, `E9`, `F`) alongside the existing category selectors keeps the shipped set stable across ruff versions. The categories stay whole (all of `UP`, not ruff's subset of it), so upgrades still pick up new rules we've opted into. Net rule change is what the version bump should be: `UP038` removed upstream, `UP042`, `UP050`, and `ISC004` added. Exclude `*.md`. Ruff 0.16 formats Python code blocks in Markdown by default, which rewrites changelogs and doc examples that are deliberately partial. This repo already runs prettier with `--embedded-language-formatting off`, so opting out keeps one owner for Markdown. Pin `plain` as third-party for isort. Ruff 0.16 resolves namespace packages per-submodule, so a checkout with part of `plain` on disk sorted bare `plain` as first-party while `plain.postgres` stayed third-party, splitting one namespace across two blocks. Pinning it makes grouping identical everywhere and is a no-op for projects that install Plain from PyPI. This regroups imports across the repo so they match what a Plain app sees. Fix the violations the new rules found: wrap implicit string concatenations inside collections (`ISC004`), and suppress `UP042` on `TextChoices`, which can't become a `StrEnum` without losing its overridden `__str__` and `_generate_next_value_`. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VeLG1nWiLA3tFMWfGwMiQV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upgrades ruff
0.12.0→0.16.0(lockfile), and raises theplain.codefloor fromruff>=0.1.0toruff>=0.16.0.Ruff 0.16 changes two defaults that
plain.codeinherits. Becauseruff_defaults.tomlships to every Plain project and the old floor was>=0.1.0, both would have reached users through a transitive ruff resolve without them changing anything — so most of this PR is pinning the config so the shipped rule set stops moving with ruff's.Default rule set:
extend-select→selectRuff 0.16 grew its built-in default selection from 59 rules to 413.
ruff_defaults.tomlusedextend-select, which layers on top of that default, soplain code checkwent from 155 rules to 445 and reported 1474 errors across this repo (RUF012×427,DTZ001×96,BLE001×94, …).Spelling out the old base (
E4,E7,E9,F) alongside the existing category selectors makes the shipped set version-independent. The category selectors stay whole —"UP"still means every stableUPrule, not the subset ruff now defaults to — so upgrades continue to pick up new rules inside a category we've opted into.Net rule change is what a version bump should be:
UP038UP042,UP050,ISC004Markdown
Ruff 0.16 lints and formats Python code blocks inside Markdown, on by default. Left alone it reformats historical CHANGELOGs and doc examples that are deliberately partial.
ruff_defaults.tomlnow setsextend-exclude = ["*.md"].This also keeps a single owner for Markdown in this repo —
scripts/fixalready runs prettier with--embedded-language-formatting off. Documented as an FAQ in theplain.codeREADME, since users reading ruff's release notes may expect the new behavior.isort and the
plainnamespaceRuff 0.16 resolves namespace packages per-submodule. In a checkout with part of
plainon disk (this monorepo —plain/sits at the project root), bareplainsorted as first-party whileplain.postgresstayed third-party, splitting one namespace across two import blocks.known-third-party = ["plain"]makes grouping identical everywhere. It's a no-op for projects that install Plain from PyPI, where ruff already resolvesplainas third-party. This is what regroups imports across 230+ files here — mechanical, and the result now matches what a Plain app sees.Violations fixed
ISC004— wrapped implicit string concatenations inside collection literals (plain-postgreshealth runner,tools/server-worker-test.py).UP042— suppressed onTextChoices. It can't become anenum.StrEnumwithout losing its deliberately overridden__str__and_generate_next_value_.plain-postgres/plain/postgres/expressions.py(lambda + conditional parenthesization).Verification
ruff check/ruff format --check/ty check/ annotations — all pass.oxlint/oxfmtwere not exercised — the binary download fails TLS in the sandbox. Untouched by this change.Follow-up worth considering separately
Ruff's new defaults are a curated set aimed at severe issues, and a lot of it looks worth having (
RUF012mutable class defaults,DTZnaive datetimes,BLE001blind excepts). Adopting any of it means fixing hundreds of real violations, so it should be a deliberate pass rather than a side effect of a version bump.Generated by Claude Code