diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..18e73e9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +# Pre-commit hooks mirroring the CI lint job (.github/workflows/ci.yml). +# ruff rev is pinned to match requirements-dev.txt so local == CI. +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.0 + hooks: + - id: ruff + name: ruff check + args: ["--config", "custom_components/andersen_ev/ruff.toml"] + files: ^custom_components/andersen_ev/.*\.py$ + - id: ruff-format + name: ruff format + args: ["--config", "custom_components/andersen_ev/ruff.toml"] + files: ^custom_components/andersen_ev/.*\.py$ diff --git a/README.md b/README.md index 830aa76..baa0e6f 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,26 @@ data: device_id: "YOUR_DEVICE_ID" ``` +## Development + +### pre-commit + +This repo ships a `.pre-commit-config.yaml` that runs the same ruff lint and +format checks as CI (pinned to the same ruff version), so issues are caught +locally before you push. To enable it: + +```bash +pip install pre-commit # or: pip install -r requirements-dev.txt +pre-commit install +``` + +The hooks then run automatically on `git commit`. To run them across the +integration source on demand: + +```bash +pre-commit run --all-files +``` + ## Future development Frankly depends on whether or not I sell my house (with the charger). diff --git a/requirements-dev.txt b/requirements-dev.txt index 6505d78..5e26147 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,3 +5,4 @@ pytest pytest-asyncio pytest-cov mypy +pre-commit