fix: error on hooks configured but no matching files - #90
Merged
Conversation
Previously a ::notice:: — now fails like the inverse case (files exist but hook missing), enforcing full bidirectional coverage strictness. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ineedjet
force-pushed
the
fix/strict-precommit-coverage-check
branch
from
July 2, 2026 22:45
500218c to
17c7ada
Compare
Merge load_hook_defs into needed_hooks, merge load_config + baseline_configured_hooks into configured_hooks, use walrus operators for missing/extra checks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR tightens the check-precommit-sync enforcement so that .pre-commit-config.yaml, workflow linters, and the repository’s actual file types must remain fully consistent in both directions (missing hooks and superfluous hooks now fail CI).
Changes:
- Treat “hooks configured but no matching files found” as
::error::(and fail the check) instead of::notice::. - Refactor hook-definition and repository-file scanning logic for the sync check script.
- Minor cleanup of subprocess output handling and control flow (
:=assignments).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+26
to
+33
| def needed_hooks(files): | ||
| with open(BASELINE_ROOT / ".pre-commit-hooks.yaml") as f: | ||
| hook_defs = yaml.safe_load(f) | ||
| return { | ||
| h["id"] for h in hook_defs | ||
| if ("types" in h and any(set(h["types"]).issubset(file_tags(f)) for f in files)) | ||
| or ("files" in h and any(re.search(h["files"], str(f)) for f in files)) | ||
| } |
Inlined comprehension was recompiling the regex and recreating the types set for every file, and changed the types/files priority order. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts the
extrahooks case from::notice::to::error::, making coverage checking fully bidirectional:.pre-commit-config.yaml.pre-commit-config.yaml≠ workflowlintersThis enforces that
linters,.pre-commit-config.yaml, and actual repo file types are always in full agreement.🤖 Generated with Claude Code