Add prek hook to forbid double backticks in docstrings#1828
Merged
nathanjmcdougall merged 4 commits intomainfrom Apr 7, 2026
Merged
Add prek hook to forbid double backticks in docstrings#1828nathanjmcdougall merged 4 commits intomainfrom
nathanjmcdougall merged 4 commits intomainfrom
Conversation
- 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>
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
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
nathanjmcdougall
approved these changes
Apr 7, 2026
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.
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-substringsastmodule — checks only docstring content, no false positives from code or comments--patternargs for arbitrary forbidden regex patterns; files passed by pre-commitConfigured 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/andhooks/.Skill update
usethis-python-codeSKILL.md updated to note thatcheck-docstring-substringsenforces the convention automatically (v1.7 → v1.8).