diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ea73e31 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.0 + hooks: + - id: ruff-check + args: [--fix] + - id: ruff-format diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 917fd22..ef45a30 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,6 +6,18 @@ Run all commands below from the repository root. See [README.md](README.md) for Before committing, format the modified code and pass the corresponding checks. +### Pre-commit + +Install [pre-commit](https://pre-commit.com/) and enable the Git hook in your local clone: + +```bash +python -m pip install pre-commit +pre-commit install +pre-commit run --all-files # Optional: check the whole repository +``` + +The hook runs Ruff checks and formatting on staged Python files. If it changes a file, review and stage the changes before committing again. Each contributor must install the hook in their own clone. + ### Python Ruff is configured in [pyproject.toml](pyproject.toml).