From 4b97bedbf446545a5c4d5fca91493a12455ce691 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Wed, 28 Oct 2026 09:10:00 +0000 Subject: [PATCH 1/3] Add pre-commit --- .github/workflows/main.yml | 47 ++++++++++++++++------------------- .github/workflows/publish.yml | 1 - .pre-commit-config.yaml | 25 +++++++++++++++++++ pyproject.toml | 1 - 4 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7b3cef1..54fbd50 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,3 @@ -name: Tests - on: push: branches: @@ -17,7 +15,28 @@ concurrency: cancel-in-progress: true jobs: + pre-commit: + name: Pre-commit + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + with: + python-version: "3.14" + + - name: Run pre-commit + run: pipx run pre-commit run --all-files --show-diff-on-failure + run: + name: Tests + needs: pre-commit runs-on: ${{ matrix.os }} timeout-minutes: 3 @@ -52,32 +71,8 @@ jobs: - name: Test installation without nbdime run: pytest -v - - name: Test flake8 - if: ${{ matrix.python-version == '3.14' }} - run: flake8 matplotlib_inline --ignore=E501,W504,W503 - - name: Test Build if: ${{ matrix.python-version == '3.14' }} run: | pip install build python -m build - - - name: Install ruff - if: ${{ matrix.python-version == '3.14' }} - run: pip install ruff - - - name: Check code with ruff - if: ${{ matrix.python-version == '3.14' }} - run: ruff check matplotlib_inline - - - name: Check formatting with ruff - if: ${{ matrix.python-version == '3.14' }} - run: ruff format matplotlib_inline --check - - - name: install Mypy - if: ${{ matrix.python-version == '3.14' }} - run : pip install mypy matplotlib - - - name: run mypy - if: ${{ matrix.python-version == '3.14' }} - run: mypy . diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7df3051..49fa0b4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -44,4 +44,3 @@ jobs: fi - name: Publish package uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..8debbd2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-added-large-files + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + exclude: \.ipynb$ + - id: trailing-whitespace + exclude: \.ipynb$ + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.17.3 + hooks: + - id: ruff-check + exclude: \.ipynb$ + - id: ruff-format + exclude: \.ipynb$ + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v2.4.0 + hooks: + - id: mypy + additional_dependencies: [matplotlib, traitlets] diff --git a/pyproject.toml b/pyproject.toml index 2a2718b..0ac7fb5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,6 @@ inline = "matplotlib_inline.backend_inline" [project.optional-dependencies] test = [ - "flake8", "nbdime", "nbval", "notebook", From 55061c7b1180fb42486c6a7fc2aea5fc3e7d243d Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Wed, 28 Oct 2026 09:50:35 +0000 Subject: [PATCH 2/3] Fix --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 54fbd50..266ee5e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,3 +1,5 @@ +name: Tests + on: push: branches: @@ -35,7 +37,7 @@ jobs: run: pipx run pre-commit run --all-files --show-diff-on-failure run: - name: Tests + name: Build and test needs: pre-commit runs-on: ${{ matrix.os }} timeout-minutes: 3 From 44e215c6f0f755ac4f3fdda7b0a1fb26eddf218c Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Wed, 28 Oct 2026 10:20:14 +0000 Subject: [PATCH 3/3] Use org-defined pre-commit CI run only --- .github/workflows/main.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 266ee5e..3fd23f1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,28 +17,8 @@ concurrency: cancel-in-progress: true jobs: - pre-commit: - name: Pre-commit - runs-on: ubuntu-latest - timeout-minutes: 5 - - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - - name: Setup Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: "3.14" - - - name: Run pre-commit - run: pipx run pre-commit run --all-files --show-diff-on-failure - run: name: Build and test - needs: pre-commit runs-on: ${{ matrix.os }} timeout-minutes: 3