From 7c9fb85792dd0981a5e1ff93e2a47778bf233f4a Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Tue, 24 Feb 2026 11:16:50 +1300 Subject: [PATCH 1/5] Migrate to `prek` --- .github/copilot-instructions.md | 2 +- .github/workflows/ci.yml | 9 ++------- CONTRIBUTING.md | 4 ++-- pyproject.toml | 1 + uv.lock | 28 ++++++++++++++++++++++++++++ 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 06f3742..029d85f 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -19,7 +19,7 @@ - We use Python 3.12, so ensure that the code is compatible and up to date with this version. - When adding a new package that requires installation, add it using `uv add ` so it gets properly declared. - When running a CLI such as `pytest`, always run it using `uv run`, e.g. `uv run pytest`. -- Always run `uv run pre-commit run --all-files` to determine whether your code is compliant with the pre-commit hooks, including linters. +- Always run `uv run prek run --all-files` to determine whether your code is compliant with the pre-commit hooks, including linters. - When importing internal modules, do not include the "src" folder in the import path as it is already defined in pyproject.toml - Limit line length to 100 characters. - Never create functions that return more than one output value (i.e. Never return tuples). Use dedicated return classes. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4591eea..18da989 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,11 +30,6 @@ jobs: with: persist-credentials: false - - name: Setup git user config - run: | - git config --global user.name placeholder - git config --global user.email placeholder@example.com - - name: Set up uv uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1 with: @@ -48,10 +43,10 @@ jobs: env: PYTHON_VERSION: ${{ matrix.python-version }} - - name: Run pre-commit + - name: Run prek if: matrix.checks run: | - uv run pre-commit run --all-files + uv run prek run --all-files - name: Run pyright if: matrix.checks diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ef97fb4..0a97e58 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,11 +22,11 @@ uv sync ### Pre-commit Hooks -This project uses the `pre-commit` framework to manage Git hooks. To install the hooks, +This project uses the `prek` framework to manage Git hooks. To install the hooks, run: ```shell -uv run pre-commit install +uv run prek install ``` ## Testing diff --git a/pyproject.toml b/pyproject.toml index 4243c8c..90a25a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,7 @@ dev = [ "pip>=25.1.1", "pre-commit>=4.2.0", "pre-commit-update>=0.8.0", + "prek>=0.3.3", "pyinstrument>=5.1.1", "pyright[nodejs]>=1.1.403", "ruff>=0.13.2", diff --git a/uv.lock b/uv.lock index 133cd53..cf873f1 100644 --- a/uv.lock +++ b/uv.lock @@ -872,6 +872,7 @@ dev = [ { name = "pip" }, { name = "pre-commit" }, { name = "pre-commit-update" }, + { name = "prek" }, { name = "pyinstrument" }, { name = "pyright", extra = ["nodejs"] }, { name = "ruff" }, @@ -915,6 +916,7 @@ dev = [ { name = "pip", specifier = ">=25.1.1" }, { name = "pre-commit", specifier = ">=4.2.0" }, { name = "pre-commit-update", specifier = ">=0.8.0" }, + { name = "prek", specifier = ">=0.3.3" }, { name = "pyinstrument", specifier = ">=5.1.1" }, { name = "pyright", extras = ["nodejs"], specifier = ">=1.1.403" }, { name = "ruff", specifier = ">=0.13.2" }, @@ -2279,6 +2281,30 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d6/a4/f002e27559d8dc6722ea744b1ef28577437087fcf8ca5126a8dc43787b35/pre_commit_update-0.8.0-py3-none-any.whl", hash = "sha256:bd43a9bb7b5fff432b1634d357d0228bc1067a19e09666f104db43b24e26238a", size = 19209, upload-time = "2025-06-30T08:27:47.762Z" }, ] +[[package]] +name = "prek" +version = "0.3.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bf/f1/7613dc8347a33e40fc5b79eec6bc7d458d8bbc339782333d8433b665f86f/prek-0.3.3.tar.gz", hash = "sha256:117bd46ebeb39def24298ce021ccc73edcf697b81856fcff36d762dd56093f6f", size = 343697, upload-time = "2026-02-15T13:33:28.723Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2d/8b/dce13d2a3065fd1e8ffce593a0e51c4a79c3cde9c9a15dc0acc8d9d1573d/prek-0.3.3-py3-none-linux_armv6l.whl", hash = "sha256:e8629cac4bdb131be8dc6e5a337f0f76073ad34a8305f3fe2bc1ab6201ede0a4", size = 4644636, upload-time = "2026-02-15T13:33:43.609Z" }, + { url = "https://files.pythonhosted.org/packages/01/30/06ab4dbe7ce02a8ce833e92deb1d9a8e85ae9d40e33d1959a2070b7494c6/prek-0.3.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:4b9e819b9e4118e1e785047b1c8bd9aec7e4d836ed034cb58b7db5bcaaf49437", size = 4651410, upload-time = "2026-02-15T13:33:34.277Z" }, + { url = "https://files.pythonhosted.org/packages/d4/fc/da3bc5cb38471e7192eda06b7a26b7c24ef83e82da2c1dbc145f2bf33640/prek-0.3.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:bf29db3b5657c083eb8444c25aadeeec5167dc492e9019e188f87932f01ea50a", size = 4273163, upload-time = "2026-02-15T13:33:42.106Z" }, + { url = "https://files.pythonhosted.org/packages/b4/74/47839395091e2937beced81a5dd2f8ea9c8239c853da8611aaf78ee21a8b/prek-0.3.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:ae09736149815b26e64a9d350ca05692bab32c2afdf2939114d3211aaad68a3e", size = 4631808, upload-time = "2026-02-15T13:33:20.076Z" }, + { url = "https://files.pythonhosted.org/packages/e2/89/3f5ef6f7c928c017cb63b029349d6bc03598ab7f6979d4a770ce02575f82/prek-0.3.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:856c2b55c51703c366bb4ce81c6a91102b70573a9fc8637db2ac61c66e4565f9", size = 4548959, upload-time = "2026-02-15T13:33:36.325Z" }, + { url = "https://files.pythonhosted.org/packages/b2/18/80002c4c4475f90ca025f27739a016927a0e5d905c60612fc95da1c56ab7/prek-0.3.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3acdf13a018f685beaff0a71d4b0d2ccbab4eaa1aced6d08fd471c1a654183eb", size = 4862256, upload-time = "2026-02-15T13:33:37.754Z" }, + { url = "https://files.pythonhosted.org/packages/c5/25/648bf084c2468fa7cfcdbbe9e59956bbb31b81f36e113bc9107d80af26a7/prek-0.3.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0f035667a8bd0a77b2bfa2b2e125da8cb1793949e9eeef0d8daab7f8ac8b57fe", size = 5404486, upload-time = "2026-02-15T13:33:39.239Z" }, + { url = "https://files.pythonhosted.org/packages/8b/43/261fb60a11712a327da345912bd8b338dc5a050199de800faafa278a6133/prek-0.3.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d09b2ad14332eede441d977de08eb57fb3f61226ed5fd2ceb7aadf5afcdb6794", size = 4887513, upload-time = "2026-02-15T13:33:40.702Z" }, + { url = "https://files.pythonhosted.org/packages/c7/2c/581e757ee57ec6046b32e0ee25660fc734bc2622c319f57119c49c0cab58/prek-0.3.3-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:c0c3ffac16e37a9daba43a7e8316778f5809b70254be138761a8b5b9ef0df28e", size = 4632336, upload-time = "2026-02-15T13:33:25.867Z" }, + { url = "https://files.pythonhosted.org/packages/d5/d8/aa276ce5d11b77882da4102ca0cb7161095831105043ae7979bbfdcc3dc4/prek-0.3.3-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:a3dc7720b580c07c0386e17af2486a5b4bc2f6cc57034a288a614dcbc4abe555", size = 4679370, upload-time = "2026-02-15T13:33:22.247Z" }, + { url = "https://files.pythonhosted.org/packages/70/19/9d4fa7bde428e58d9f48a74290c08736d42aeb5690dcdccc7a713e34a449/prek-0.3.3-py3-none-musllinux_1_1_armv7l.whl", hash = "sha256:60e0fa15da5020a03df2ee40268145ec5b88267ec2141a205317ad4df8c992d6", size = 4540316, upload-time = "2026-02-15T13:33:24.088Z" }, + { url = "https://files.pythonhosted.org/packages/25/b5/973cce29257e0b47b16cc9b4c162772ea01dbb7c080791ea0c068e106e05/prek-0.3.3-py3-none-musllinux_1_1_i686.whl", hash = "sha256:553515da9586d9624dc42db32b744fdb91cf62b053753037a0cadb3c2d8d82a2", size = 4724566, upload-time = "2026-02-15T13:33:29.832Z" }, + { url = "https://files.pythonhosted.org/packages/d6/8b/ad8b2658895a8ed2b0bc630bf38686fe38b7ff2c619c58953a80e4de3048/prek-0.3.3-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:9512cf370e0d1496503463a4a65621480efb41b487841a9e9ff1661edf14b238", size = 4995072, upload-time = "2026-02-15T13:33:27.417Z" }, + { url = "https://files.pythonhosted.org/packages/fd/b7/0540c101c00882adb9d30319d22d8f879413598269ecc60235e41875efd4/prek-0.3.3-py3-none-win32.whl", hash = "sha256:b2b328c7c6dc14ccdc79785348589aa39850f47baff33d8f199f2dee80ff774c", size = 4293144, upload-time = "2026-02-15T13:33:46.013Z" }, + { url = "https://files.pythonhosted.org/packages/97/c7/e4f11da653093040efba2d835aa0995d78940aea30887287aeaebe34a545/prek-0.3.3-py3-none-win_amd64.whl", hash = "sha256:3d7d7acf7ca8db65ba0943c52326c898f84bab0b1c26a35c87e0d177f574ca5f", size = 4652761, upload-time = "2026-02-15T13:33:32.962Z" }, + { url = "https://files.pythonhosted.org/packages/11/e4/d99dec54c6a5fb2763488bff6078166383169a93f3af27d2edae88379a39/prek-0.3.3-py3-none-win_arm64.whl", hash = "sha256:8aa87ee7628cd74482c0dd6537a3def1f162b25cd642d78b1b35dd3e81817f60", size = 4367520, upload-time = "2026-02-15T13:33:31.664Z" }, +] + [[package]] name = "prompt-toolkit" version = "3.0.52" @@ -3323,6 +3349,8 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/6b/fa/3234f913fe9a6525a7b97c6dad1f51e72b917e6872e051a5e2ffd8b16fbb/ruamel.yaml.clib-0.2.14-cp314-cp314-macosx_15_0_arm64.whl", hash = "sha256:70eda7703b8126f5e52fcf276e6c0f40b0d314674f896fc58c47b0aef2b9ae83", size = 137970, upload-time = "2025-09-22T19:51:09.472Z" }, { url = "https://files.pythonhosted.org/packages/ef/ec/4edbf17ac2c87fa0845dd366ef8d5852b96eb58fcd65fc1ecf5fe27b4641/ruamel.yaml.clib-0.2.14-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a0cb71ccc6ef9ce36eecb6272c81afdc2f565950cdcec33ae8e6cd8f7fc86f27", size = 739639, upload-time = "2025-09-22T19:51:10.566Z" }, { url = "https://files.pythonhosted.org/packages/15/18/b0e1fafe59051de9e79cdd431863b03593ecfa8341c110affad7c8121efc/ruamel.yaml.clib-0.2.14-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:e7cb9ad1d525d40f7d87b6df7c0ff916a66bc52cb61b66ac1b2a16d0c1b07640", size = 764456, upload-time = "2025-09-22T19:51:11.736Z" }, + { url = "https://files.pythonhosted.org/packages/e7/cd/150fdb96b8fab27fe08d8a59fe67554568727981806e6bc2677a16081ec7/ruamel_yaml_clib-0.2.14-cp314-cp314-win32.whl", hash = "sha256:9b4104bf43ca0cd4e6f738cb86326a3b2f6eef00f417bd1e7efb7bdffe74c539", size = 102394, upload-time = "2025-11-14T21:57:36.703Z" }, + { url = "https://files.pythonhosted.org/packages/bd/e6/a3fa40084558c7e1dc9546385f22a93949c890a8b2e445b2ba43935f51da/ruamel_yaml_clib-0.2.14-cp314-cp314-win_amd64.whl", hash = "sha256:13997d7d354a9890ea1ec5937a219817464e5cc344805b37671562a401ca3008", size = 122673, upload-time = "2025-11-14T21:57:38.177Z" }, ] [[package]] From db804ece59661d6d21771771e9deb0c58bcea92e Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Tue, 24 Feb 2026 11:27:01 +1300 Subject: [PATCH 2/5] Set up prek in its own CI job --- .github/workflows/ci.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18da989..3fcec5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,15 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: + prek: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + - name: Run Prek + uses: j178/prek-action@0bb87d7f00b0c99306c8bcb8b8beba1eb581c037 # v1.1.1 tests: name: Run Tests and Checks runs-on: ${{ matrix.os }} @@ -43,11 +52,6 @@ jobs: env: PYTHON_VERSION: ${{ matrix.python-version }} - - name: Run prek - if: matrix.checks - run: | - uv run prek run --all-files - - name: Run pyright if: matrix.checks run: | From 8de5b7de331eabfbb4f08e65d4393adbe7f18780 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Tue, 24 Feb 2026 11:28:06 +1300 Subject: [PATCH 3/5] Update task scripts --- tasks/scripts/configure_project.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/scripts/configure_project.sh b/tasks/scripts/configure_project.sh index 5a9e61e..1978cc7 100644 --- a/tasks/scripts/configure_project.sh +++ b/tasks/scripts/configure_project.sh @@ -1,14 +1,14 @@ #!/bin/bash -output=$(uv pip show pre-commit &> /dev/null) +output=$(uv pip show prek &> /dev/null) if [ $? -eq 0 ] then - echo Installing pre-commit hooks... - output=$(uv run pre-commit install 2>&1) + echo Installing prek hooks... + output=$(uv run prek install 2>&1) if [ $? -ne 0 ] then echo "$output" - echo "Error: pre-commit install failed." + echo "Error: prek install failed." exit 1 fi fi From dbcd0ac1585ab0841ef4e589de613b34343bb020 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Tue, 24 Feb 2026 11:29:52 +1300 Subject: [PATCH 4/5] Move prek out of its own CI job --- .github/workflows/ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fcec5e..e5752f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,15 +19,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - prek: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - persist-credentials: false - - name: Run Prek - uses: j178/prek-action@0bb87d7f00b0c99306c8bcb8b8beba1eb581c037 # v1.1.1 tests: name: Run Tests and Checks runs-on: ${{ matrix.os }} @@ -52,6 +43,9 @@ jobs: env: PYTHON_VERSION: ${{ matrix.python-version }} + - name: Run Prek + uses: j178/prek-action@0bb87d7f00b0c99306c8bcb8b8beba1eb581c037 # v1.1.1 + - name: Run pyright if: matrix.checks run: | From a08948c1c6777370f85786b3b5cc367b68b70db3 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Tue, 24 Feb 2026 11:39:54 +1300 Subject: [PATCH 5/5] Restore local prek approach --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5752f5..f9de323 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,9 @@ jobs: PYTHON_VERSION: ${{ matrix.python-version }} - name: Run Prek - uses: j178/prek-action@0bb87d7f00b0c99306c8bcb8b8beba1eb581c037 # v1.1.1 + if: matrix.checks + run: | + uv run --frozen prek run --all-files - name: Run pyright if: matrix.checks