Fix broken bandit pre-commit hook (Unknown test found in profile)#1
Open
Ho1yShif wants to merge 1 commit into
Open
Fix broken bandit pre-commit hook (Unknown test found in profile)#1Ho1yShif wants to merge 1 commit into
Ho1yShif wants to merge 1 commit into
Conversation
The upstream PyCQA/bandit pre-commit hook installs bandit from a shallow git clone, where pbr resolves the package version to 0.0.0. That broken metadata breaks bandit's plugin-id registration, so config load fails with "Unknown test found in profile: B104" on *every* commit — blocking commits and CI for anyone using the repo. (Pinning additional_dependencies to a real version instead surfaces the same root cause as a hard pip conflict: "bandit 0.0.0 ... and bandit==1.9.4 have conflicting dependencies".) Switch to a repo:local python hook that installs a properly built PyPI wheel (bandit[toml]==1.9.4). Verified: `pre-commit run bandit --all-files` now passes; the pyproject skips list was always valid. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Problem
pre-commit run banditfails at config load on every file:B104(and the rest of theskipslist inpyproject.toml) are all valid bandit test IDs — so the config content was never the bug. The real cause is in the hook's install:PyCQA/banditpre-commit repo builds bandit from a shallow git clone, wherepbrcan't read the tag and resolves the version to0.0.0.B104read as "unknown" and config load aborts (exit 2).additional_dependencies: ["bandit[toml]==1.9.4"]on the same hook just surfaces the same root cause as a hard pip conflict:bandit 0.0.0 (from repo) and bandit==1.9.4 have conflicting dependencies.This blocked commits and CI for everyone — both prior template PRs had to use
git commit --no-verify.Fix
Replace the upstream git hook with a
repo: localpython hook that installs a properly built PyPI wheel (bandit[toml]==1.9.4) instead of the broken git-source build. All args/excludes are preserved.Verification
No change to
pyproject.toml— the[tool.bandit]skipslist was always correct.🤖 Generated with Claude Code