From 78aa8beea7851b0e613ce29b004cb681f677ab2f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 31 Mar 2025 10:50:54 +0200 Subject: [PATCH] Run ruff and yapf in pre-commit --- .github/workflows/main.yml | 11 ++++++----- .pre-commit-config.yaml | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2f7c5ef5..ece8480f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,6 +18,11 @@ jobs: steps: - uses: actions/checkout@v4 - run: ./check-license.sh + PreCommit: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - run: pipx run pre-commit run --all-files Envvars: runs-on: ubuntu-22.04 outputs: @@ -43,16 +48,12 @@ jobs: strategy: matrix: python-version: ${{ fromJSON(needs.Envvars.outputs.version_matrix) }} - task: [Typecheck, Lint, Ruff, Yapf, Test] + task: [Typecheck, Lint, Test] include: - task: Typecheck cmd: pytype -j auto . - task: Lint cmd: pylint --rcfile .pylintrc --recursive yes . - - task: Ruff - cmd: ruff check - - task: Yapf - cmd: yapf . -drp - task: Test cmd: pytest steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..a99fde92 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +# Learn more about this config here: https://pre-commit.com + +# To enable these pre-commit hooks: +# 1. Install pre-commit: `pip install pre-commit` +# or if you are using pipx: `pipx install pre-commit` +# or if you are using uv: `uv tool install pre-commit`. +# Then in the project root directory run `pre-commit install` + +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.11.2 + hooks: + - id: ruff + + - repo: https://github.com/google/yapf + rev: v0.43.0 + hooks: + - id: yapf + args: [--in-place, --recursive, --parallel]