Skip to content

Refactor tests, scripts and the rules tool, then select every ruff rule (ALL) - #3934

Draft
anth-volk wants to merge 36 commits into
ruff-complexity-applicationfrom
ruff-complexity-tests-scripts
Draft

anth-volk wants to merge 36 commits into
ruff-complexity-applicationfrom
ruff-complexity-tests-scripts

Conversation

@anth-volk

@anth-volk anth-volk commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #3931

Summary

Phase 1 step 1.8, group 8b, part 3 of 3: tests, scripts and the rules tool, refactored within ruff's complexity limits, then select = ["ALL"]. Stacked on #3933. This completes step 1.8.

  • All 64 findings in scope are fixed, with no complexity suppressions.
  • Rules tool (scripts/rules/, still standard-library only and runnable on Python 3.11):
    • The command line, registry loading, enforcer descriptions, the Mermaid graph, validation and the workflow parser are split into helpers and lookup tables.
    • 35 new unittests pin its command line, schema, validation (all 41 ordered violations from a fixture registry) and rendered output.
    • Old and new versions gave byte-identical output across every real workflow, about 3,000 generated workflows and 500 generated registries.
  • Scripts: the collector verifier, baseline capture, Cloud Run load generator, household mirror command and local boot smoke test now take grouped values, and status codes are HTTPStatus members. Each command-line interface is unchanged: the same --help text, output and exit codes. New tests cover each script.
  • Tests:
    • Long tests split into assertion helpers.
    • Fixtures grouped into composite fixtures or case values.
    • Route tables replace long if chains in the v1 contract test.
    • No assertion was dropped, and collected test IDs are unchanged apart from the 71 added.
  • ALL:
    • pyproject.toml selects every rule, and ignores only the two that conflict with ruff format (COM812, ISC001) and one of each mutually exclusive docstring pair (D203, D213).
    • The registered per-file exemptions are unchanged: tests, generated Alembic revisions, and the rules tool's unittest tests for PT.
    • ALL found one new finding, a tuple-valued test enum without __slots__, which gets its own commit.
  • Registry and docs:
    • api.quality.ruff-lint now lists ALL, and its statement gives the four ignores and why.
    • The rules-registry skill doc says every rule applies and that a ruff upgrade PR fixes any new rule's violations.

Testing

  • The make test set at this branch's tip: 2,919 passed, which is the base's 2,433 plus 166, 249 and this PR's 71.
  • The rules tool's unittests (109) pass on Python 3.11 and on the venv's Python.
  • uvx ruff@0.15.12 check . (with ALL) and ruff format --check . are clean. Ruff reports no formatter conflicts.
  • make typecheck-v2 is clean.
  • mypy outside the gate:
    • The changed files that already existed show no new errors, and 9 fewer than the base.
    • The 23 new characterization test files from parts 1 and 2 have 152 mypy errors, mostly no-untyped-def. Tests are outside the mypy gate and exempt from annotation rules.
  • Every model schema and pre-existing adapter, the FastAPI OpenAPI, the /v2/openapi.json preview and the legacy spec are byte-identical to ruff-idioms-arguments, with and without OLD_SIMULATION_GATEWAY_URL set.
  • CI/CD: no workflow changed. The changed .github scripts read the same environment variables in the same order. The collector's COLLECTOR_ID_TOKEN and GOOGLE_OAUTH_ACCESS_TOKEN are exported by verify_observability_collector.sh from gcloud. OBSERVABILITY_PROJECT_ID and OBSERVABILITY_METRIC_LOCATION come from vars.* in deploy-observability-collector.yml. I haven't checked that those repository variables exist in GitHub's settings.
  • CI: above the bottom of its stack, so only CI complete runs until the PRs below merge.

🤖 Generated with Claude Code

@anth-volk
anth-volk added this pull request to stack #3917 October 14, 2026 18:47
@anth-volk anth-volk changed the title ruff complexity tests scripts Refactor tests, scripts and the rules tool, then select every ruff rule (ALL) Oct 14, 2026
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch 3 times, most recently from 17fa756 to 375bd46 Compare October 14, 2026 21:13
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch from 375bd46 to dac4ae8 Compare October 14, 2026 21:53
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch 5 times, most recently from c88d8f4 to f627fef Compare October 15, 2026 15:21
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch from f627fef to 50c6a00 Compare October 15, 2026 15:45
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch 2 times, most recently from 01d6600 to 874f2ca Compare October 16, 2026 05:40
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch 2 times, most recently from 1b571c7 to 86958ae Compare October 16, 2026 06:40
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch 2 times, most recently from b7c5336 to bbe5bc7 Compare October 16, 2026 06:59
…utput

Characterization tests before the complexity refactors: the command line's
output and exit status for every command, the ordered schema and validation
violations for malformed registries, enforcer descriptions, mermaid graphs,
CI test-collection checks and every field the workflow reader extracts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 29 commits October 16, 2026 11:05
The reader handles one key line at a time: step tracking, one-line
values, run: block scalars and matrix entries each get a method.
parse_jobs hands the jobs body to a helper that splits it into jobs, and
the two-character quote check gets a named constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Characterization tests for the version bump inference, the changelog
fetch, the collector verifier's Google Cloud reads and delivery wait, the
baseline capture's request probes, the migration contract workflow
guard, the household event command's audit records and proxy port, the
v1 metadata difference shapes, the Cloud Run load generator and the
local boot smoke test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…scripts

HTTP statuses use http.HTTPStatus; the changelog fragment and Alembic
metadata difference lengths get named constants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alue

verify and _wait_for_delivery take a CloudReadback (project, metric
location and access token) and the delivery wait takes the
VerificationProbe, instead of six separate arguments. The command line
and the environment variables it reads are unchanged; a 404 is named
HTTPStatus.NOT_FOUND.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_client_loop takes the cell's settings, deadlines and record list as one
_LoadCellRun instead of seven arguments, and status classification names
its codes with http.HTTPStatus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e value

The command's arguments, output and environment variables are unchanged;
the highest TCP port gets a named constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Health checks compare against HTTPStatus.OK; the output, exit status and
process handling are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fake budget-window result becomes a keyword-only dataclass, and the
request bodies and expected response subsets move from if-chains into
tables keyed by path and method. Each lookup returns a fresh copy, as
the if-chains did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_mock_reform_impact drops three parameters no test ever passed,
create_mock_budget_window_batch_execution takes the batch's year-by-year
progress as one MockBatchProgress, and the cached-error test takes its
service, parameters and mocks through one composite fixture, set up in
the same order as before. The request-plumbing test's running-years poll
passes its progress as a MockBatchProgress too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each region is a keyword-only _Region whose source() returns the same
mutable SimpleNamespace the registry held before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The household-lock test's before_cursor_execute listener uses
SQLAlchemy's named=True form, so it no longer spells out six arguments
it ignores. The user-policy route tests' _association_read drops the
country, user and policy parameters no caller passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each case is a _PersistenceFailure, and the test IDs are rebuilt to
match the ones pytest generated for the seven separate parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…motion checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rage checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The typed-failure worker becomes a small transport class whose app name
the test switches for the retry, the version routes, setup options,
stored impacts and economy requests become helpers, and the recorded
failure checks move into two assertion helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each downgrade target gets its own assertion helper and every return to
head shares one upgrade-check-assert helper; the migration commands, SQL
and assertions run in the same order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The helpers extracted from long tests and the new characterization
tests get annotations; JSON bodies and ORM rows the tests index stay
typed as Any, and the rules loader's downgrade reason is typed as str.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Selecting every ruff rule turns on SLOT001, which asks tuple subclasses to
define __slots__. The enum-normalization test's tuple-valued enum gets an
empty __slots__; its members, values and normalization are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every rule family now passes, so pyproject.toml selects ALL instead of the
per-group list. It ignores COM812 and ISC001, which conflict with ruff
format (ruff's documentation says to disable them with the formatter), and
D203 and D213, which are mutually exclusive with the kept D211 and D212.
The per-file ignores and namespace packages are unchanged.

The api.quality.ruff-lint rule's enforcer codes become ["ALL"], which the
rules tool's select check and hidden-rule discovery both accept as is, and
its statement names the four ignores and why. The rendered rules page and
the AGENTS.md rules block are regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#3891's user-route credential check took the contract workflow guard's
_check_workflows past the complexity limit (C901). Each request's key
now comes from _request_key and its problems from _request_violations,
which runs the same checks in the same order, so the guard reports the
same violations in the same order; the pinned workflow-guard test and
the credential tests pass unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n factory

#3916 gave create_mock_modal_execution a run_progress parameter, its
sixth (PLR0913), but no test passes it: both callers build the default
execution. The factory now always reports no run progress, as every
caller already received; the tests that relay progress build their
executions directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#3891's previous-revision test picks a value for each required column
through _test_value, whose type checks exceeded the complexity and
return limits (C901, PLR0911). The type checks move to TYPED_TEST_VALUES,
an ordered table that keeps Enum ahead of its String base, so every
column gets the same value as before; the lifecycle tests pass against a
disposable PostgreSQL 17 database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#3891's live signed-in lifecycle and signed-out upgrade tests exceeded
the statement limit (PLR0915). Each saved resource's round trip runs in
_assert_saved_resource_lifecycle, which takes the resource, its v1
field and id as one _SavedResource; the linked reform, report and export
checks run in _assert_export_links_the_saved_reform; and the signed-out
saving checks run in _assert_signed_out_saving. The requests, their
bodies and order, and the assertions are unchanged. (The stack's split
of the earlier live policy lifecycle test no longer applies: #3891
replaced that test.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#3891's test that signed-in user resources log Supabase sources took
five parametrized arguments besides monkeypatch (PLR0913). Each case is
now a _UserResourceRequest, and the test IDs are rebuilt to match the
ones pytest generated for the five separate parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch from bbe5bc7 to 1204051 Compare October 16, 2026 07:05

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor tests, scripts and the rules tool, then select every ruff rule (ALL)

1 participant