Menu

#195 chore: add a pre-commit config (ruff + lint-imports)

open
nobody
2026-08-29
2026-07-30
Anonymous
No

Originally created by: fu351
Originally owned by: jonah-boop

What

The repo has no pre-commit config anywhere (verified: no .pre-commit-config.yaml, no pre-commit dependency in pyproject.toml, no mention in CONTRIBUTING.md). Contributors currently only find out they broke ruff check / ruff format / lint-imports when CI runs (.github/workflows/ci.yml). Add a .pre-commit-config.yaml at the repo root running ruff check --fix, ruff format, and lint-imports as local git hooks, and document pre-commit install as an optional step in CONTRIBUTING.md's "Local setup" section.

Difficulty: level-2

Mechanical: no application code changes — transcribe the same ruff/lint-imports invocations CI already runs into a pre-commit config, so it fails the same way CI does.

Safety constraints (do not weaken these)

  • The pre-commit config only runs the same checks CI already enforces (ruff check, ruff format --check, lint-imports) — do not add --unsafe-fixes or any autofix mode that could silently rewrite security-relevant logic (e.g. the redaction/canonicalization helpers) without a human reviewing the diff.
  • pre-commit is a local, optional convenience — it must not become a required CI gate in this issue (CI already gates independently) and must not change any command's actual behavior, only when contributors are warned about it.

Starting files

  • Repo root — new .pre-commit-config.yaml.
  • pyproject.toml — add pre-commit to the dev optional-dependencies group.
  • CONTRIBUTING.md — "Local setup" section (lines 8–17); add a pre-commit install step.

Acceptance criteria

  • [ ] .pre-commit-config.yaml runs ruff check, ruff format --check, and lint-imports on pre-commit run --all-files.
  • [ ] pre-commit is added to pyproject.toml's dev extras.
  • [ ] CONTRIBUTING.md documents pip install -e ".[dev]"pre-commit install as an optional local step.
  • [ ] Existing behaviour unchanged (no test weakened, no output format broken)
  • [ ] ruff check . && ruff format --check . and lint-imports pass
  • [ ] pytest passes

How to validate

pip install -e ".[dev]"
pre-commit install
pre-commit run --all-files

Out of scope

  • Do not make pre-commit a required CI step in this issue — it stays a local convenience.
  • Do not add any autofix hook beyond ruff check --fix / ruff format (no --unsafe-fixes).

Notes for contributors

New here? Start with CONTRIBUTING.md. Issues are labelled level-1 (docs only) through level-10 (new subsystem) — pick one at your level and climb. Comment to claim an issue before starting.

Related

Tickets: #195
Tickets: #328

Discussion

  • Anonymous

    Anonymous - 2026-08-17

    Originally posted by: fu351

    Re-leveled 6 → 2 and marked good-first. This is a .pre-commit-config.yaml running ruff and lint-imports to mirror the CI commands — a copy-and-map job that's genuinely a good first contribution, not a level-6.

     
  • Anonymous

    Anonymous - 2026-08-18

    Originally posted by: jonah-boop

    I’d like to take this issue.

    I verified the current CONTRIBUTING.md, pyproject.toml, and CI workflow. My planned scope is:

    • add root .pre-commit-config.yaml hooks for the existing CI commands: ruff check ., ruff format --check ., and lint-imports;
    • use pass_filenames: false so each hook checks the same repository scope as CI;
    • add pre-commit to the dev extra;
    • document pre-commit install as an optional local step; and
    • run pre-commit run --all-files plus the repository’s full documented quality gates before opening the PR.

    One scope point: the issue prose mentions ruff check --fix / ruff format, while the acceptance criteria and “mirror CI” requirement specify the non-mutating ruff check / ruff format --check commands. I’ll follow the non-mutating acceptance criteria unless you prefer otherwise.

    I’ll keep this to one focused tooling/docs PR and disclose AI assistance in the PR description, as required by the contribution guide.

     
  • Anonymous

    Anonymous - 2026-08-18

    Originally posted by: fu351

    @jonah-boop That is a model claim comment: you verified the config against CI before asking, and you caught the one real discrepancy in the issue text. Go with the non-mutating pair (ruff check, ruff format --check). The acceptance bar is "fails the same way CI does", and a --fix hook mutates at commit time, which CI never does. Your five-point scope is right, including pass_filenames: false. It's yours - assigning now.

    Quick community roll-call: are you in the Doberman Discord? If yes, drop your handle here (or DM me there) so I can match the GitHub side of your work to your Discord name. If not, you're warmly invited: https://discord.gg/Sfy5XGNqty

     
  • Anonymous

    Anonymous - 2026-08-18
     
  • Anonymous

    Anonymous - 2026-08-29

    Originally posted by: fu351

    @jonah-boop checking in on [#195], no rush. If anything about the pre-commit setup is unclear ask here and I'll help. If you've moved on that's fine too, just let me know and I'll unassign it.

     

    Related

    Tickets: #195


Log in to post a comment.