From 4f42f51bd2c29ef0fbb66b441e5b70cb5f781932 Mon Sep 17 00:00:00 2001 From: Ariel Richtman <10679234+arichtman@users.noreply.github.com> Date: Fri, 2 Sep 2022 03:01:28 +1000 Subject: [PATCH] Add pre-commit hook (#55) --- .pre-commit-config.yaml | 5 +++++ .pre-commit-hooks.yaml | 7 +++++++ README.md | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..2bfdae39cb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: + - repo: https://github.com/charliermarsh/ruff + rev: v0.0.23 + hooks: + - id: lint diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000000..5c0f6484e0 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,7 @@ +- id: lint + name: ruff lint + description: Run ruff to lint Python files. + entry: ruff + language: python + types_or: [python] + pass_filenames: true diff --git a/README.md b/README.md index 025b00e9dc..1b848f9a6f 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,16 @@ You can run ruff in `--watch` mode to automatically re-run on-change: ruff path/to/code/ --watch ``` +ruff also works with [Pre-Commit](https://pre-commit.com) (requires Cargo on system): + +```yaml +repos: +- repo: https://github.com/charliermarsh/ruff + rev: v0.0.23 + hooks: + - id: lint +``` + ## Configuration ruff is configurable both via `pyproject.toml` and the command line.