From 271decdb4c2047a572bd0ba979dca21dd1e35987 Mon Sep 17 00:00:00 2001 From: Jamie Nelson Date: Mon, 31 Aug 2026 17:42:19 +1000 Subject: [PATCH] fix(ruff): stop `ruff check` from mutating the tree `fix = true` under `[tool.ruff]` applies to every `ruff check` invocation in the repo, including CI. The lint job (`uv run ruff check --output-format=github packages/`) was therefore rewriting its own checkout and exiting 0: it inserted the `required-imports` entry missing from `packages/ensure_uv/__init__.py`, reported success, and threw the fix away. The committed source was never lint-clean, and the file ruff-check produced would itself have failed `ruff format --check` (no blank line after the module docstring) had the two jobs shared a checkout. - Add the missing `from __future__ import annotations` so the committed tree is genuinely clean under both `ruff check` and `ruff format --check`. - Drop `fix = true`. Autofix is now requested at the call site, which is already this repo's convention: the pre-commit ruff hook passes `args: [--fix]` explicitly, and a developer wanting autofix runs `ruff check --fix`. - Pass `--no-fix` in the CI lint job so the "must never mutate" requirement is stated where it is required, not only inherited from shared config. `unsafe-fixes = true` is kept: it only widens which fixes apply once fixing has been explicitly requested, so it is no longer reachable from a plain `ruff check`. Verified: with the violation reintroduced, the CI lint command exits 1 and leaves the file untouched. --- .github/workflows/test.yml | 2 +- packages/ensure_uv/__init__.py | 2 ++ pyproject.toml | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa3e840..4ef4935 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,7 +62,7 @@ jobs: run: uv sync - name: Lint code - run: uv run ruff check --output-format=github packages/ + run: uv run ruff check --no-fix --output-format=github packages/ continue-on-error: false typecheck: diff --git a/packages/ensure_uv/__init__.py b/packages/ensure_uv/__init__.py index 7d79ce9..92f055f 100644 --- a/packages/ensure_uv/__init__.py +++ b/packages/ensure_uv/__init__.py @@ -1,5 +1,7 @@ """Pre-commit hook to ensure uv is installed and available.""" +from __future__ import annotations + from .main import main from .version import __version__ diff --git a/pyproject.toml b/pyproject.toml index f371c8b..3599ecf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,6 @@ testpaths = ["tests"] include = ["packages"] [tool.ruff] -fix = true src = [".github", ".gitlab", "packages", "scripts", "tests", "typings"] target-version = "py311" unsafe-fixes = true