You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add pre-commit hooks to automatically catch formatting, linting, and other code quality issues before commit, preventing CI failures like the one seen in PR #125 (Black formatting issues).
Problem
Current State:
Developers can commit code without running formatters/linters
CI catches issues after PR creation (wasting time and CI resources)
## Development Setup1. Install dependencies:
```bash
poetry install
Install pre-commit hooks:
poetry run pre-commit install
(Optional) Run hooks manually:
poetry run pre-commit run --all-files
**CONTRIBUTING.md**:
```markdown
### Pre-commit Hooks
This project uses pre-commit hooks to ensure code quality. Hooks run automatically before each commit.
**First-time setup:**
```bash
poetry run pre-commit install
Skip hooks (not recommended):
git commit --no-verify
Run hooks manually:
poetry run pre-commit run --all-files
## Example Workflow
**Before (Current):**
```bash
# Developer makes changes
git add .
git commit -m "Add feature"
git push
# CI fails due to formatting
# Developer fixes formatting
git add .
git commit -m "Fix formatting"
git push
# CI passes (2 commits, wasted time)
Summary
Add pre-commit hooks to automatically catch formatting, linting, and other code quality issues before commit, preventing CI failures like the one seen in PR #125 (Black formatting issues).
Problem
Current State:
poetry run black .poetry run ruff check .poetry run ty check .Pain Points:
Solution
Add pre-commit hooks to run checks automatically before each commit:
Benefits:
Implementation
1. Add
.pre-commit-config.yaml2. Update
pyproject.tomlAdd pre-commit to dev dependencies:
3. Update CI Workflow
Option A: Keep full CI checks (redundant but thorough)
# No changes - CI runs everything as backupOption B: Skip formatting checks in CI (pre-commit handles it)
4. Update Documentation
README.md:
Install pre-commit hooks:
(Optional) Run hooks manually:
Skip hooks (not recommended):
Run hooks manually:
After (With Pre-commit):
Configuration Options
Fast Mode (Recommended)
Run only fast checks automatically:
pre-commit run --hook-stage manual)Strict Mode
Run all checks including type checking:
Compatibility
With uv (#126)
Pre-commit works seamlessly with uv:
With Existing Workflows
--no-verify)pre-commit run --all-files)Implementation Plan
Phase 1: Setup
.pre-commit-config.yamlwith basic hookspre-commit run --all-filesPhase 2: Documentation
Phase 3: CI Integration
Phase 4: Team Onboarding
Edge Cases
Large Codebase
Pre-commit only runs on staged files (fast):
Automated Fixes
Some hooks auto-fix issues:
--fixSkipping Hooks
When needed (emergencies, WIP commits):
git commit --no-verify -m "WIP: work in progress"Success Metrics
Expected Improvements:
Real Example:
Related Issues
Resources
Labels
enhancementdevx(developer experience)tooling