Skip to content

refactor: enforce consistent lint and formatting with pre-commit and CI - #20

Merged
mambo-wang merged 4 commits into
mambo-wang:developfrom
LiberiFatali:refactor/precommit-enforce
Aug 27, 2026
Merged

refactor: enforce consistent lint and formatting with pre-commit and CI#20
mambo-wang merged 4 commits into
mambo-wang:developfrom
LiberiFatali:refactor/precommit-enforce

Conversation

@LiberiFatali

Copy link
Copy Markdown
Contributor

Why

The recent CI failure was caused by small lint and formatting issues that were only caught after pushing. This PR makes those checks happen earlier — on the developer's machine before commit — and re-enables them as a required CI check, so the same failure won't happen again.

What this PR does

  • One-time cleanup: Formats the whole codebase with a single tool so all files are now consistent. Future blame views ignore this commit.
  • One formatter: Removes the duplicate black setup and keeps ruff as the single source of truth for both linting and formatting.
  • Local guard: Adds a pre-commit hook (ruff check + ruff format) that auto-fixes simple issues on every commit.
  • Remote guard: Restores the formatting check in CI on changed files — it can't be bypassed, even if the hook is skipped locally.
  • Guide: Adds CONTRIBUTING.md with setup and usage instructions.

How to use after this lands

uv sync --frozen
uv run pre-commit install   # run once
# hooks run automatically on commit; run manually with:
uv run pre-commit run --all-files

Hooks fix what they can locally; CI is the final gate. mypy remains available locally (uv run mypy) but is not enforced.

@LiberiFatali

Copy link
Copy Markdown
Contributor Author

@mambo-wang Many of the code changes involve only reformatting. I have confirmed that all tests passed.

- Format whole repo with ruff (one-time cleanup, 206 files)
- Drop black, pin ruff==0.16.3, keep mypy as optional
- Add pre-commit hook (ruff check --fix + ruff format) and restore CI format check on changed files
- Add CONTRIBUTING.md and .git-blame-ignore-revs for blame hygiene
- Fix remaining lint issues (bare except, F821) and ignore E402 for intentional sys.path imports

Prevents repeat of CI failure #33059834372 where lint errors were only caught after push.
@LiberiFatali
LiberiFatali force-pushed the refactor/precommit-enforce branch from 729a121 to 50c8ab8 Compare August 27, 2026 12:56
LiberiFatali and others added 3 commits August 27, 2026 19:58
Contributors must fork mambo-wang/CodeWiki-Plus first, clone their
fork, and add upstream remote — direct clone of upstream is read-only.

@mambo-wang mambo-wang left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and verified locally against the merge base (e92692b1):

  • Blast-radius check: AST-compared all 184 changed .py files. Differences are limited to quote normalization, docstring whitespace normalization, signature re-wrapping, and F401 import removals. Every removed import was cross-checked repo-wide for re-export/consumer usage — none found (e.g. ComponentMeta consumers already import from codewiki.mcp.cache; validate_api_key consumers import from utils.validation directly).
  • Runtime: full test suite passes (428 passed / 2 skipped; the single failure in test_review_changes.py::test_prepare_end_to_end reproduces on the develop baseline and is pre-existing). Repo-wide ruff check . and ruff format --check . are green.
  • MCP surface: tools/list (44 tools), prompts/list (18) and resources/list (3) are byte-identical between base and head; live tools/call smoke tests succeed.

Two non-blocking follow-ups after merge: (1) append the actual squash-merge commit hash to .git-blame-ignore-revs (currently placeholder-only, and the suggested --grep string does not match this commit's message); (2) heads-up that the PR also reformats embedded Python code blocks in 24 markdown files — harmless, though generated repowiki/ docs will get the old formatting back on regeneration.

@mambo-wang
mambo-wang merged commit 48fb8aa into mambo-wang:develop Aug 27, 2026
2 checks passed
@LiberiFatali
LiberiFatali deleted the refactor/precommit-enforce branch August 27, 2026 15:52
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.

2 participants