[FEAT]: Add pre-commit to run tox lint/format #54
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dunwright/git-herald#54
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Before you submit
Problem Statement
Add pre-commit to run tox lint/format
Proposed Solution
Add pre-commit to run tox lint/format
Alternatives Considered
No response
Additional Context
How-To: Set Up Pre-commit with Tox
This guide covers integrating pre-commit with your existing tox configuration to automatically format, lint, and test code before commits and pushes.
Prerequisites
lint,format, and test environmentspyproject.tomlortox.iniwith ruff and mypy configured undertox -e lintandtox -e formatPhilosophy
Rather than duplicating tool configuration in both tox and pre-commit, this setup uses pre-commit purely as a trigger for existing tox environments. This means:
tox.iniandpyproject.toml.pre-commit-config.yamltox -e lintmanually gives identical results to the pre-commit hookThe test suite is intentionally kept out of pre-commit and CI lint checks, and instead runs on
pre-push. This avoids slow commits while still catching failures before code reaches the remote.pre-commitgit commitpre-pushgit push1. Install pre-commit
2. Create
.pre-commit-config.yamlIn your project root:
3. Install the git hooks
Both hooks must be installed separately. Running only
pre-commit installwill not install the pre-push hook.4. How it works
On every
git commit:tox -e formatruns first — auto-fixes ruff formatting and import order in placetox -e lintruns next — checks ruff and mypyOn every
git push:tox -e py313runs the full test suite against Python 3.13Bypassing hooks
You can skip hooks when needed, for example on WIP branches or draft PRs:
Use this sparingly — the hooks exist to catch issues before they reach CI or other contributors.
Running hooks manually
To run all pre-commit hooks against all files without making a commit:
To run a specific hook:
Uninstalling hooks
This removes the git hooks but leaves
.pre-commit-config.yamlin place.