From c23518fff007431933bf7e1192e49098756e57df Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Dec 2023 13:20:45 +0100 Subject: [PATCH 1/4] Add pre-commit Signed-off-by: Christian Clauss --- .github/workflows/precommit.yml | 21 ++++++++++++++++++ .pre-commit-config.yaml | 39 +++++++++++++++++++++++++++++++++ pyproject.toml | 21 +++++++++--------- 3 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/precommit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml new file mode 100644 index 00000000..430b7aa1 --- /dev/null +++ b/.github/workflows/precommit.yml @@ -0,0 +1,21 @@ +# https://pre-commit.com +# This GitHub Action assumes that the repo contains a valid .pre-commit-config.yaml file. +# Using pre-commit.ci is even better that using GitHub Actions for pre-commit. +name: pre-commit +on: + pull_request: + branches: [master] + push: + workflow_dispatch: +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - run: pip install pre-commit + - run: pre-commit --version + - run: pre-commit install + - run: pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..a525891e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,39 @@ +# Learn more about this config here: https://pre-commit.com/ + +# To enable these pre-commit hooks run: +# `brew install pre-commit` or `python3 -m pip install pre-commit` +# Then in the project root directory run `pre-commit install` + +# default_language_version: +# python: python3 +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-builtin-literals + # - id: check-executables-have-shebangs + # - id: check-shebang-scripts-are-executable + - id: check-toml + - id: check-xml + - id: check-yaml + # - id: detect-private-key + # - id: end-of-file-fixer + # - id: mixed-line-ending + # - id: trailing-whitespace + + #- repo: https://github.com/codespell-project/codespell + # rev: v2.2.6 + # hooks: + # - id: codespell # See pyproject.toml for args + # additional_dependencies: + # - tomli + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.1.9 + hooks: + - id: ruff # See pyproject.toml for args + + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.15 + hooks: + - id: validate-pyproject diff --git a/pyproject.toml b/pyproject.toml index 54f37420..2cda2733 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,24 +1,23 @@ [tool.ruff] -line-length = 167 - +exclude = ["test/lib/python/*"] +extend-select = [ + "S", # Bandit + "E9", + "F63", + "F7", + "F82", + "I", +] ignore = [ "E402", # TODO: enable "E711", # TODO: enable - "E711", # TODO: enable "E712", # TODO: enable "E721", # TODO: enable "S101", # TODO: enable "S110", # TODO: enable "S324", # TODO: enable ] -extend-select = [ - "S", # Bandit - "E9", - "F63", - "F7", - "F82", - "I", -] +line-length = 167 [tool.ruff.per-file-ignores] "{test,tests,examples}/**/*.py" = [ From 56354c5fff02e7c5797cf6fe70fd3061adaa2834 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Dec 2023 14:48:41 +0100 Subject: [PATCH 2/4] Update .github/workflows/precommit.yml --- .github/workflows/precommit.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 430b7aa1..0fe5a544 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -17,5 +17,4 @@ jobs: python-version: 3.x - run: pip install pre-commit - run: pre-commit --version - - run: pre-commit install - run: pre-commit run --all-files From 13980b6c69c90ad0273974e5af760254aaf96528 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Dec 2023 20:09:03 +0100 Subject: [PATCH 3/4] Update .github/workflows/precommit.yml Co-authored-by: Pierre Fersing --- .github/workflows/precommit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 0fe5a544..09069e27 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -15,6 +15,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.x - - run: pip install pre-commit + - use: pre-commit/action@v3.0.0 - run: pre-commit --version - run: pre-commit run --all-files From 5b35edec06ebb493a7ecd21212bcffb0a326f1fe Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Dec 2023 20:17:29 +0100 Subject: [PATCH 4/4] Update .github/workflows/precommit.yml Co-authored-by: Pierre Fersing --- .github/workflows/precommit.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 09069e27..8e225b19 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -15,6 +15,4 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.x - - use: pre-commit/action@v3.0.0 - - run: pre-commit --version - - run: pre-commit run --all-files + - uses: pre-commit/action@v3.0.0