From d055090dd2e3cf010c8f865eba4dbecb698ff8a8 Mon Sep 17 00:00:00 2001 From: Dunedan Date: Fri, 23 Aug 2024 14:32:22 +0200 Subject: [PATCH] Add ruff pre-commit hook Add configuration for pre-commit, ruff as a hook and configuration to run ruff whenever a pull request is opened or code is pushed. --- .gitea/workflows/pre-commit.yml | 12 ++++++++++++ .pre-commit-config.yaml | 15 +++++++++++++++ ruff.toml | 10 ++++++++++ 3 files changed, 37 insertions(+) create mode 100644 .gitea/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml create mode 100644 ruff.toml diff --git a/.gitea/workflows/pre-commit.yml b/.gitea/workflows/pre-commit.yml new file mode 100644 index 0000000000..0237934358 --- /dev/null +++ b/.gitea/workflows/pre-commit.yml @@ -0,0 +1,12 @@ +--- +name: pre-commit +on: + - push + - pull_request +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..fd58227677 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,15 @@ +--- +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.1 + hooks: + - id: ruff + args: + - --output-format=full + exclude: ^source/tools/webservices/ + - id: ruff-format + args: + - --check + - --target-version + - py311 + exclude: ^source/tools/webservices/ diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000000..4ca9e6080d --- /dev/null +++ b/ruff.toml @@ -0,0 +1,10 @@ +line-length = 99 + +[lint.isort] +lines-after-imports = 2 + +[lint.pycodestyle] +max-doc-length = 72 + +[lint.pydocstyle] +convention = "pep257"