Skip to content

Add prek hook to forbid double backticks in docstrings#1828

Merged
nathanjmcdougall merged 4 commits intomainfrom
copilot/add-prek-hook-forbid-double-backticks-again
Apr 7, 2026
Merged

Add prek hook to forbid double backticks in docstrings#1828
nathanjmcdougall merged 4 commits intomainfrom
copilot/add-prek-hook-forbid-double-backticks-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

Agents and developers sometimes write RST-style double-backtick markup ( foo ) in docstrings when single backticks should be used. This adds a bespoke prek hook to catch these automatically.

Hook: check-docstring-substrings

  • Parses Python files via ast module — checks only docstring content, no false positives from code or comments
  • Accepts --pattern args for arbitrary forbidden regex patterns; files passed by pre-commit
  • Reports file/line/column for each violation

Configured with regex (?<!)(?!`).+?(?<!`)(?!) which matches double-backtick pairs while correctly ignoring triple backticks (code fences).

Existing violations fixed

24 double-backtick occurrences replaced with single backticks across 11 files in src/ and hooks/.

Skill update

usethis-python-code SKILL.md updated to note that check-docstring-substrings enforces the convention automatically (v1.7 → v1.8).

Copilot AI and others added 2 commits April 6, 2026 19:58
- Create hooks/check-docstring-substrings.py: parses Python files via AST,
  checks only docstring content against forbidden regex patterns, reports
  file/line/column of violations
- Add hook entry to .pre-commit-config.yaml with regex pattern forbidding
  RST-style double-backtick code spans
- Fix 24 existing double-backtick violations across src/ and hooks/
- Update usethis-python-code SKILL.md to mention hook enforcement (v1.7->1.8)

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/ce16af45-2d48-47f2-ad42-d27adfb53177

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Add prek hook to forbid double backticks in docstrings Add prek hook to forbid double backticks in docstrings Apr 6, 2026
Copilot AI requested a review from nathanjmcdougall April 6, 2026 20:01
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review April 7, 2026 01:06
@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-forbid-double-backticks-again (1c083d9) with main (6626b42)

Open in CodSpeed

@nathanjmcdougall nathanjmcdougall merged commit 61f88eb into main Apr 7, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/add-prek-hook-forbid-double-backticks-again branch April 7, 2026 02:44
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 double backticks in docstrings

2 participants