Skip to content

build: point lint tasks at pre-commit - #1369

Open
davidberenstein1957 wants to merge 2 commits into
masterfrom
fix/lint-tasks
Open

build: point lint tasks at pre-commit#1369
davidberenstein1957 wants to merge 2 commits into
masterfrom
fix/lint-tasks

Conversation

@davidberenstein1957

@davidberenstein1957 davidberenstein1957 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Fixes the task lint / task format tasks so they run what CI actually enforces.

What changed

-precommit = "c"
-lint = "black --check --diff . && ruff check . && mypy ."
-format = "black . && ruff check --fix --exit-non-zero-on-fix ."
+precommit = "pre-commit run --all-files"
+format = "pre-commit run --all-files"

Also drops the now-unreferenced ruff dev dependency, and removes the docs-check-drift task, which pointed at scripts/check-docs-drift.py — a file that does not exist.

Why

There is no ruff config anywhere in the repo, ruff is not in .pre-commit-config.yaml, and .github/workflows/pre-commit.yml is the only lint job in CI. So ruff check . was running against its own defaults, unrelated to the style the codebase is written in and never gating anything. mypy . likewise walked carbonserver/ and webapp/ rather than the -m codecarbon scope the existing mypy-check task uses.

The practical effect was that anyone following CLAUDE.md's instruction to run these before submitting got ~1300 findings and ~120 rewritten files on an otherwise clean tree — and ruff's SIM117 autofix rewrote a nested with in tests/test_powermetrics.py into syntactically invalid Python.

Verification

$ uv run task format
autoflake................................................................Passed
isort....................................................................Passed
black....................................................................Passed
flake8...................................................................Passed

Passes clean on origin/master, matching uv run pre-commit run --all-files.

Notes for review

  • The lint task is gone, not aliased. pre-commit checks and fixes in one pass, so a lint task pointing at it would rewrite the working tree — the opposite of what someone typing lint expects. There is one task, format, and docs/how-to/agent-instructions.md (a.k.a. CLAUDE.md) now points at it.
  • Dropping mypy from the lint path is deliberate. mypy . walked carbonserver/ and webapp/ instead of the package, it is not in .pre-commit-config.yaml and not in CI, so it gated nothing while producing noise. mypy-check, scoped to -m codecarbon, is untouched and still available for anyone who wants a type check.
  • Removing ruff from the dev group is deliberate: leaving an unconfigured, unenforced linter installed is what caused this. If the project wants ruff, it should land as a configured pre-commit hook with the codebase brought into line in its own PR.

Closes #1368

🤖 Generated with Claude Code

`task lint` and `task format` ran `ruff` and `mypy .`, neither of which
this repo enforces: there is no ruff config anywhere, ruff is absent from
.pre-commit-config.yaml, and CI (.github/workflows/pre-commit.yml) runs
pre-commit only. The result was that both tasks reported ~1300 findings
and rewrote ~120 otherwise-clean files, and one ruff SIM117 autofix
produced syntactically invalid code in tests/test_powermetrics.py.

Both tasks now run pre-commit, matching CI exactly. On current master
they pass clean.

Also drops the unreferenced `ruff` dev dependency, fixes the `precommit`
task (its command was the stray string "c"), and removes
`docs-check-drift`, which pointed at scripts/check-docs-drift.py — a file
that does not exist.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.43%. Comparing base (065d0e6) to head (5f12ba9).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1369      +/-   ##
==========================================
+ Coverage   91.39%   91.43%   +0.03%     
==========================================
  Files          49       49              
  Lines        5056     5056              
==========================================
+ Hits         4621     4623       +2     
+ Misses        435      433       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@davidberenstein1957
davidberenstein1957 marked this pull request as ready for review August 12, 2026 19:14
@davidberenstein1957
davidberenstein1957 requested a review from a team as a code owner August 12, 2026 19:14
davidberenstein1957 added a commit that referenced this pull request Aug 13, 2026
#1369 removes the taskipy black/ruff tasks entirely, which is the root-cause
fix for the format drift: pinning a second toolchain to match pre-commit keeps
two copies of the same version truth in sync by hand. Take the deletion there
instead and leave these unpinned so the two branches do not conflict.

[tool.black] target-version stays: the pre-commit black hook reads pyproject
too, so that fix is orthogonal to #1369 and still wanted.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

task lint and task format run tools the project does not enforce

1 participant