From 47c4d9578c99adbf7fa37950825709ae7206fdc3 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 19 Feb 2024 13:11:01 +0200 Subject: [PATCH] Add pre-commit configuration (#1467) --- .pre-commit-config.yaml | 13 +++++++++++++ docs/source/developer_guides/contributing.md | 8 ++++++++ 2 files changed, 21 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..1563cffda8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.2.1 + hooks: + - id: ruff + args: + - --fix + - id: ruff-format + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-merge-conflict + - id: check-yaml diff --git a/docs/source/developer_guides/contributing.md b/docs/source/developer_guides/contributing.md index bb7c47ad2e..ee25ea38b1 100644 --- a/docs/source/developer_guides/contributing.md +++ b/docs/source/developer_guides/contributing.md @@ -41,6 +41,14 @@ make quality # just check make style # check and fix ``` +You can also set up [`pre-commit`](https://pre-commit.com/) to run these fixes +automatically as Git commit hooks. + +```bash +$ pip install pre-commit +$ pre-commit install +``` + Running all the tests can take a couple of minutes, so during development it can be more efficient to only run tests specific to your change: ```sh