This project uses pre-commit to automatically format and lint code before commits.
-
Install pre-commit (if not already installed):
pip install pre-commit
-
Install the git hooks:
pre-commit install
The pre-commit hooks run the following checks:
- black: Python code formatting (line length: 127)
- isort: Import statement sorting
- flake8: Python linting (configured in setup.cfg)
- trailing-whitespace: Removes trailing whitespace
- end-of-file-fixer: Ensures files end with a newline
- check-yaml: Validates YAML syntax
- check-added-large-files: Prevents large files from being committed
- check-merge-conflict: Detects merge conflict markers
- mixed-line-ending: Ensures consistent line endings
- rstcheck: Validates RST documentation files
To run all hooks on all files (useful after initial setup or major changes):
pre-commit run --all-filesTo run hooks on specific files:
pre-commit run --files path/to/file1.py path/to/file2.pyTo skip hooks for a single commit (not recommended):
git commit --no-verify- Pre-commit hooks are configured in
.pre-commit-config.yaml - Flake8 and isort settings are in
setup.cfg - clang-format style is configured in
.clang-format
The same linting checks run in GitHub Actions CI, so passing pre-commit locally ensures CI will pass.