Skip to content

Add prek hook to forbid banned comment keywords (pragma:, type: ignore)#1833

Merged
nathanjmcdougall merged 3 commits intomainfrom
copilot/add-prek-hook-forbidding-banned-comments
Apr 7, 2026
Merged

Add prek hook to forbid banned comment keywords (pragma:, type: ignore)#1833
nathanjmcdougall merged 3 commits intomainfrom
copilot/add-prek-hook-forbidding-banned-comments

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Agents and developers occasionally introduce # pragma: no cover or # type: ignore[...] comments. This project doesn't use coverage pragmas (write tests instead) and uses pyright, not mypy, for type checking.

New hook: hooks/check-comment-keywords.py

  • Uses Python's tokenize module to inspect only comment tokens — no false positives from strings or docstrings
  • Accepts --keyword (repeatable) via CLI, keeping the script project-agnostic
  • Wired into .pre-commit-config.yaml applying to all Python files via types: [python]:
- id: check-comment-keywords
  name: check-comment-keywords
  entry: uv run --frozen --offline hooks/check-comment-keywords.py
  args: ["--keyword", "pragma:", "--keyword", "type: ignore"]
  language: system
  types: [python]
  priority: 0

Cleanup of existing violations

  • Removed 6 # type: ignore[union-attr] comments from src/usethis/_deps.py and src/usethis/_file/pyproject_toml/deps.py — these were mypy suppressions unnecessary under ty/basedpyright

Skills used: usethis-prek-hook-bespoke-create, usethis-qa-static-checks, usethis-lesson-create, usethis-github-issue-create

…olations

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/6152a7f0-e37e-4368-970d-9759057f1234

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Add prek hook to forbid banned comment keywords Add prek hook to forbid banned comment keywords (pragma:, type: ignore) Apr 7, 2026
Copilot AI requested a review from nathanjmcdougall April 7, 2026 02:55
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review April 7, 2026 03:42
Comment thread .pre-commit-config.yaml Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 7, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/add-prek-hook-forbidding-banned-comments (e6bcb6a) with main (61f88eb)

Open in CodSpeed

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/a1d3a492-0348-4ae1-9584-932216cf89dd

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
@nathanjmcdougall nathanjmcdougall merged commit 5d57925 into main Apr 7, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/add-prek-hook-forbidding-banned-comments branch April 7, 2026 04:28
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.

Add prek hook to forbid banned comment keywords (pragma, type:)

2 participants