Skip to content

Fix CI: pin black to the version it actually runs - #100

Open
audiodude wants to merge 2 commits into
mainfrom
fix-ci-black
Open

Fix CI: pin black to the version it actually runs#100
audiodude wants to merge 2 commits into
mainfrom
fix-ci-black

Conversation

@audiodude

@audiodude audiodude commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

The problem

tox.ini declares the black environment as:

[testenv:py3-black]
commands = black --check --diff quarry/web/
deps = black

Because this is unpinned, every CI run installs whatever black is newest on PyPI that day — currently 26.5.1. This results in CI going red in precisely the way the initial tox.ini comment warned against, just by a different mechanism.

This PR pins black for tox and does a slight reformat (blank lines) for the latest version.

It also drops black from `test-requirements.txt because it was currently a no-op.

Also add node_modules to the flake8 exclude to avoid errors running tox locally after building the frontend\

AI disclosure

This patch was written with AI assistance (Claude Code), per Using AI in MediaWiki patches.

🤖 Generated with Claude Code
Manually reviewed by @audiodude.

The tox py3-black environment declares `deps = black`, unpinned, so every
run installs whatever black is newest on PyPI that day. When black 26.5.1
was released it dropped a blank line after module-level imports, and CI
went red on main without a single line of this repository changing. Every
PR opened since then has inherited a failure it did not cause.

Pin the environment to black==26.5.1 and apply its formatting to the three
files that had drifted: models/base.py, utils/__init__.py and worker.py.
The change is three deleted blank lines.

Black is dropped from test-requirements.txt rather than pinned there too.
The pin in that file (black==20.8b0, from 2020) is already dead weight: it
cannot parse the `target_version = ['py311']` in pyproject.toml, so it
fails immediately if anyone runs it. It cannot be bumped in place either,
because a current black needs click >= 8 while requirements.txt pins
click==7.1.2 for celery, and pip refuses to resolve the two together. The
py3-black tox environment installs into its own virtualenv, so pinning it
there sidesteps the conflict entirely.

Also add node_modules to the flake8 exclude list. It has no effect on CI,
where the checkout is clean, but `npm run build` leaves a node_modules
directory containing a vendored flatted.py that flake8 then reports on -
so running tox locally after building the frontend fails in a way CI never
reproduces.

This patch was written with AI assistance (Claude Code). It has been
reviewed and tested by hand: all four tox environments (flake8, pytest,
black, mypy) pass in the tests/tox container.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Bug: T434789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant