Pre-commit hooks are now set up to automatically check and format code before each commit:
- Ruff: Python linter and formatter
- Auto-fixes import sorting and basic issues
- Formats code to match project style
- Basic checks: Trailing whitespace, end-of-file, YAML/JSON syntax
- Pydocstyle: Checks for missing or incorrect docstrings
When you run git commit, the hooks will:
- ✅ Automatically format your Python code
- ✅ Fix trailing whitespace and line endings
⚠️ Warn about code style issues (line length > 100, missing docstrings)
If hooks modify files, the commit will be aborted so you can review changes. Simply review the changes and commit again.
# Run all hooks on all files
uv run pre-commit run --all-files
# Run all hooks on staged files only
uv run pre-commit run
# Run specific hook
uv run pre-commit run ruff --all-files
uv run pre-commit run ruff-format --all-files
# Skip hooks for a specific commit (not recommended)
git commit --no-verifyProblem: Lines exceed 100 characters Solution: Break long lines manually or ruff will auto-format where possible
Problem: Public functions/classes/modules missing docstrings Solution: Add docstrings following Google style:
def my_function(arg1: str) -> dict:
"""Short description of what this does.
Args:
arg1: Description of arg1.
Returns:
Description of return value.
"""
passTo disable pre-commit hooks:
uv run pre-commit uninstall