Problem
Agents (and developers) sometimes add comment annotations that this project doesn't want:
# pragma: no cover — coverage exclusion comments should not be used; instead write tests to cover the code, or remove unreachable branches
# type: ignore[...] — mypy-style type suppression comments; this project uses basedpyright, and any needed type suppressions should use # pyright: ignore[...] instead
These were added in PR #1795 (src/usethis/_file/setup_cfg/deps.py) and caught in code review.
Solution
Add a prek (bespoke) hook that scans Python files and fails if any of these banned keywords are found in comments:
pragma: (catches # pragma: no cover and similar)
type: ignore (catches # type: ignore[...])
The hook should be provided via CLI, scanning all Python files in src/ and tests/, and report the file/line/column of any violations.
Implementation Notes
- This should be a bespoke prek hook (see
.agents/skills/usethis-prek-hook-bespoke-create/SKILL.md)
- The hook should accept a list of banned patterns via CLI so it's reusable
- Should report clear error messages like:
src/foo.py:42: Found banned comment keyword 'pragma:'
Problem
Agents (and developers) sometimes add comment annotations that this project doesn't want:
# pragma: no cover— coverage exclusion comments should not be used; instead write tests to cover the code, or remove unreachable branches# type: ignore[...]— mypy-style type suppression comments; this project uses basedpyright, and any needed type suppressions should use# pyright: ignore[...]insteadThese were added in PR #1795 (
src/usethis/_file/setup_cfg/deps.py) and caught in code review.Solution
Add a prek (bespoke) hook that scans Python files and fails if any of these banned keywords are found in comments:
pragma:(catches# pragma: no coverand similar)type: ignore(catches# type: ignore[...])The hook should be provided via CLI, scanning all Python files in
src/andtests/, and report the file/line/column of any violations.Implementation Notes
.agents/skills/usethis-prek-hook-bespoke-create/SKILL.md)src/foo.py:42: Found banned comment keyword 'pragma:'