Pre-commit Workflows
After reading docs on linting & formatting and typing, your committing workflow will look like:
this might get tiresome, and it doesn't have to be that way. Enter pre-commit hooks - defined workflow that run when you try to commit something. With a .pre-commit-config.yaml
(our template has one) you can have ruff & mypy executed automatically when you make a commit:
if the pre-commit hook will change formatting (and so the pre-commit check will fail), you'll have to run the two commands above again. Done.
Setup Instructions
-
Make sure pre-commit are installed
-
Install the hooks:
Common Issues and Solutions
- Hook fails to install: Ensure Python 3.12 is available in your environment
- Ruff errors: Run
ruff check --fix
manually to see detailed errors - MyPy errors: Add type annotations to resolve strict type checking issues
Best Practices
- Run
pre-commit run --all-files
after installing to verify setup - Commit frequently to catch issues early
- Update hooks regularly with
pre-commit autoupdate