Skip to content

Bump ruff to 0.15.22 and repair the lint gate - #2789

Open
symroe wants to merge 4 commits into
masterfrom
ruff-0.15.22
Open

Bump ruff to 0.15.22 and repair the lint gate#2789
symroe wants to merge 4 commits into
masterfrom
ruff-0.15.22

Conversation

@symroe

@symroe symroe commented Jul 29, 2026

Copy link
Copy Markdown
Member

Bumps ruff from 0.2.2 to 0.15.22. Largest job in the rollout.

Commit What
946864184 Version bump only. Intentionally leaves lint/format failing.
de8256b6c ruff format . — 51 of 1064 files. Mechanical.
3cb04e495 ruff check --fix . — 21 found, 2 fixed.
5f8329183 pytest-ruff 0.2.1 to 0.5 — repairs the lint gate.

The pre-commit rev moved from v0.2.2 to v0.15.22 to match.

Branch is ruff-0.15.22 with a hyphen: a local branch named ruff already
exists in this repo, which makes ruff/0.15.22 an illegal ref.

The lint gate was a no-op

pytest-ruff 0.2.1 shells out to ruff check --show-source — an argument
removed in ruff 0.5.0 — and then only inspects stdout, discarding stderr and
the exit code. Against ruff 0.15.22 the call exits 2 with nothing on stdout,
so every ruff test passed regardless of violations. 0.5 checks the return
code. Expect CI to go red on this PR.

Still failing after this PR — 19 violations

Start with F507 — it is a real bug, not a style issue:

ynr/apps/candidates/templatetags/metadescription.py:21:35  F507
ynr/apps/candidates/templatetags/metadescription.py:30:35  F507

A %-format string with 0 placeholders but 1 substitution raises
TypeError: not all arguments converted during string formatting at
runtime. Worth checking whether that template tag is reached.

SIM115 (5) — resource leaks, worth fixing properly:

ynr/apps/moderation_queue/models.py:135
ynr/apps/parties/importer.py:461
ynr/apps/parties/importer.py:482
ynr/apps/parties/tests/test_importer.py:65
ynr/storages.py:23

E721 (2) — type comparison with == rather than is/isinstance:

ynr/apps/api/views.py:17
ynr/apps/cached_counts/report_helpers.py:1240

SIM103 (10) — style, unsafe fixes only:

ynr/apps/candidates/models/popolo_extra.py:501, :519, :673
ynr/apps/data_exports/views.py:98
ynr/apps/elections/uk/lib.py:17
ynr/apps/official_documents/management/commands/official_documents_import_sopns.py:95
ynr/apps/resultsbot/importers/modgov.py:283
ynr/apps/sopn_parsing/helpers/parse_tables.py:86, :93
ynr/apps/uk_results/models.py:50

10 of the 19 have unsafe fixes available; the rest need manual work.
ruff format --check . is clean (1064 files).


Part of the org-wide rollout moving every DemocracyClub repo onto ruff 0.15.22. Commits are deliberately split so each step reviews on its own — please review commit by commit rather than as a combined diff.

symroe and others added 4 commits July 28, 2026 16:51
Version bump only, from 0.2.2. No code changes -- format and lint failures
introduced by this bump are addressed in the following commits.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Result of running `ruff format .` with 0.15.22. Mechanical only --
no behavioural changes. 51 files reformatted, 1013 files left unchanged

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Result of running `ruff check --fix .` with 0.15.22. Safe fixes only;
`--unsafe-fixes` was not used. Any remaining violations need manual
review and are listed in the PR description.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pytest-ruff 0.2.1 invoked `ruff check --show-source`, an argument removed in
ruff 0.5.0. Against ruff 0.15.22 that call fails with exit code 2 and writes
to stderr, but 0.2.1 only inspects stdout:

    stdout, _ = child.communicate()
    if stdout:
        raise RuffError(stdout.decode())

Empty stdout meant no error was ever raised, so every ruff test reported
PASSED regardless of violations -- the lint gate was a no-op.

0.5 checks the return code and raises on both 1 and 2.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@symroe symroe self-assigned this Jul 30, 2026
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.

1 participant