From f9a72639553e9b455f9c22540b1a356f53ea045f Mon Sep 17 00:00:00 2001 From: Bartosz Sokorski Date: Wed, 4 Mar 2026 12:36:20 +0100 Subject: [PATCH] Migrate from pre-commit to prek --- .github/workflows/tests.yml | 7 +-- .pre-commit-config.yaml | 27 ------------ poetry.lock | 85 ++++++++++++------------------------- prek.toml | 37 ++++++++++++++++ pyproject.toml | 2 +- 5 files changed, 66 insertions(+), 92 deletions(-) delete mode 100644 .pre-commit-config.yaml create mode 100644 prek.toml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ccf6a585..370ff980 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,14 +18,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 - with: - python-version: "3.11" - - name: "Install pre-commit" - run: pip install pre-commit - name: "Install Rust toolchain" run: rustup component add rustfmt clippy - - run: pre-commit run --all-files + - uses: j178/prek-action@0bb87d7f00b0c99306c8bcb8b8beba1eb581c037 # v1.1.1 Tests: name: ${{ matrix.os }} / ${{ matrix.python-version }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index f611b1f1..00000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,27 +0,0 @@ -ci: - autofix_prs: false - -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: trailing-whitespace - exclude: ^tests/.*/fixtures/.* - - id: end-of-file-fixer - exclude: ^tests/.*/fixtures/.* - - id: debug-statements - - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.11 - hooks: - - id: ruff - - id: ruff-format - - - repo: local - hooks: - - id: lint-rust - name: Lint Rust - entry: make lint-rust - types: [rust] - language: rust - pass_filenames: false diff --git a/poetry.lock b/poetry.lock index 4c80164b..29b66300 100644 --- a/poetry.lock +++ b/poetry.lock @@ -107,18 +107,6 @@ files = [ [package.dependencies] pycparser = "*" -[[package]] -name = "cfgv" -version = "3.4.0" -description = "Validate configuration and produce human readable error messages." -optional = false -python-versions = ">=3.8" -groups = ["lint"] -files = [ - {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, - {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, -] - [[package]] name = "chardet" version = "5.2.0" @@ -195,7 +183,7 @@ version = "0.3.9" description = "Distribution utilities" optional = false python-versions = "*" -groups = ["dev", "lint"] +groups = ["dev"] files = [ {file = "distlib-0.3.9-py2.py3-none-any.whl", hash = "sha256:47f8c22fd27c27e25a65601af709b38e4f0a45ea4fc2e710f65755fa8caaaf87"}, {file = "distlib-0.3.9.tar.gz", hash = "sha256:a60f20dea646b8a33f3e7772f74dc0b2d0772d2837ee1342a00645c81edf9403"}, @@ -223,7 +211,7 @@ version = "3.16.1" description = "A platform independent file lock." optional = false python-versions = ">=3.8" -groups = ["dev", "lint"] +groups = ["dev"] files = [ {file = "filelock-3.16.1-py3-none-any.whl", hash = "sha256:2082e5703d51fbf98ea75855d9d5527e33d8ff23099bec374a134febee6946b0"}, {file = "filelock-3.16.1.tar.gz", hash = "sha256:c249fbfcd5db47e5e2d6d62198e565475ee65e4831e2561c8e313fa7eb961435"}, @@ -252,21 +240,6 @@ python-dateutil = ">=2.8.1" [package.extras] dev = ["flake8", "markdown", "twine", "wheel"] -[[package]] -name = "identify" -version = "2.6.3" -description = "File identification library for Python" -optional = false -python-versions = ">=3.9" -groups = ["lint"] -files = [ - {file = "identify-2.6.3-py2.py3-none-any.whl", hash = "sha256:9edba65473324c2ea9684b1f944fe3191db3345e50b6d04571d10ed164f8d7bd"}, - {file = "identify-2.6.3.tar.gz", hash = "sha256:62f5dae9b5fef52c84cc188514e9ea4f3f636b1d8799ab5ebc475471f9e47a02"}, -] - -[package.extras] -license = ["ukkonen"] - [[package]] name = "iniconfig" version = "2.0.0" @@ -595,18 +568,6 @@ files = [ {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, ] -[[package]] -name = "nodeenv" -version = "1.9.1" -description = "Node.js virtual environment builder" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -groups = ["lint"] -files = [ - {file = "nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9"}, - {file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"}, -] - [[package]] name = "packaging" version = "24.2" @@ -637,7 +598,7 @@ version = "4.3.6" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.8" -groups = ["dev", "doc", "lint"] +groups = ["dev", "doc"] files = [ {file = "platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb"}, {file = "platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907"}, @@ -665,24 +626,32 @@ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] [[package]] -name = "pre-commit" -version = "3.8.0" -description = "A framework for managing and maintaining multi-language pre-commit hooks." +name = "prek" +version = "0.3.4" +description = "Better `pre-commit`, re-engineered in Rust" optional = false -python-versions = ">=3.9" +python-versions = ">=3.8" groups = ["lint"] files = [ - {file = "pre_commit-3.8.0-py2.py3-none-any.whl", hash = "sha256:9a90a53bf82fdd8778d58085faf8d83df56e40dfe18f45b19446e26bf1b3a63f"}, - {file = "pre_commit-3.8.0.tar.gz", hash = "sha256:8bb6494d4a20423842e198980c9ecf9f96607a07ea29549e180eef9ae80fe7af"}, + {file = "prek-0.3.4-py3-none-linux_armv6l.whl", hash = "sha256:c35192d6e23fe7406bd2f333d1c7dab1a4b34ab9289789f453170f33550aa74d"}, + {file = "prek-0.3.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6f784d78de72a8bbe58a5fe7bde787c364ae88f0aff5222c5c5c7287876c510a"}, + {file = "prek-0.3.4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:50a43f522625e8c968e8c9992accf9e29017abad6c782d6d176b73145ad680b7"}, + {file = "prek-0.3.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:4bbb1d3912a88935f35c6ba4466b4242732e3e3a8c608623c708e83cea85de00"}, + {file = "prek-0.3.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ca4d4134db8f6e8de3c418317becdf428957e3cab271807f475318105fd46d04"}, + {file = "prek-0.3.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7fb6395f6eb76133bb1e11fc718db8144522466cdc2e541d05e7813d1bbcae7d"}, + {file = "prek-0.3.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:aae17813239ddcb4ae7b38418de4d49afff740f48f8e0556029c96f58e350412"}, + {file = "prek-0.3.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10a621a690d9c127afc3d21c275030d364d1fbef3296c095068d3ae80a59546e"}, + {file = "prek-0.3.4-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:d978c31bc3b1f0b3d58895b7c6ac26f077e0ea846da54f46aeee4c7088b1b105"}, + {file = "prek-0.3.4-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:a8e089a030f0a023c22a4bb2ec4ff3fcc153585d701cff67acbfca2f37e173ae"}, + {file = "prek-0.3.4-py3-none-musllinux_1_1_armv7l.whl", hash = "sha256:8060c72b764f0b88112616763da9dd3a7c293e010f8520b74079893096160a2f"}, + {file = "prek-0.3.4-py3-none-musllinux_1_1_i686.whl", hash = "sha256:65b23268456b5a763278d4e1ec532f2df33918f13ded85869a1ddff761eb9697"}, + {file = "prek-0.3.4-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:3975c61139c7b3200e38dc3955e050b0f2615701d3deb9715696a902e850509e"}, + {file = "prek-0.3.4-py3-none-win32.whl", hash = "sha256:37449ae82f4dc08b72e542401e3d7318f05d1163e87c31ab260a40f425d6516e"}, + {file = "prek-0.3.4-py3-none-win_amd64.whl", hash = "sha256:60e9aa86ca65de963510ae28c5d94b9d7a97bcbaa6e4cdb5bf5083ed4c45dc71"}, + {file = "prek-0.3.4-py3-none-win_arm64.whl", hash = "sha256:486bdae8f4512d3b4f6eb61b83e5b7595da2adca385af4b2b7823c0ab38d1827"}, + {file = "prek-0.3.4.tar.gz", hash = "sha256:56a74d02d8b7dfe3c774ecfcd8c1b4e5f1e1b84369043a8003e8e3a779fce72d"}, ] -[package.dependencies] -cfgv = ">=2.0.0" -identify = ">=1.0.0" -nodeenv = ">=0.11.1" -pyyaml = ">=5.1" -virtualenv = ">=20.10.0" - [[package]] name = "py-cpuinfo" version = "9.0.0" @@ -858,7 +827,7 @@ version = "6.0.2" description = "YAML parser and emitter for Python" optional = false python-versions = ">=3.8" -groups = ["doc", "lint"] +groups = ["doc"] files = [ {file = "PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086"}, {file = "PyYAML-6.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf"}, @@ -1271,7 +1240,7 @@ version = "20.28.0" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.8" -groups = ["dev", "lint"] +groups = ["dev"] files = [ {file = "virtualenv-20.28.0-py3-none-any.whl", hash = "sha256:23eae1b4516ecd610481eda647f3a7c09aea295055337331bb4e6892ecce47b0"}, {file = "virtualenv-20.28.0.tar.gz", hash = "sha256:2c9c3262bb8e7b87ea801d715fae4495e6032450c71d2309be9550e7364049aa"}, @@ -1335,4 +1304,4 @@ test = ["time-machine"] [metadata] lock-version = "2.1" python-versions = ">=3.10" -content-hash = "edee83acf5459cf49258c09ff8fbebcc491cf24d7ff5979f0585b9ac54355431" +content-hash = "5c95cf1e26993ceeb51eb3f91f5fbdbd8acdc433c03214110adf12556a280249" diff --git a/prek.toml b/prek.toml new file mode 100644 index 00000000..c968f5af --- /dev/null +++ b/prek.toml @@ -0,0 +1,37 @@ +#:schema https://www.schemastore.org/prek.json + +[[repos]] +repo = "https://github.com/pre-commit/pre-commit-hooks" +rev = "v4.4.0" +hooks = [ + { + id = "trailing-whitespace", + exclude = "^tests/.*/fixtures/.*" + }, + { + id = "end-of-file-fixer", + exclude = "^tests/.*/fixtures/.*" + }, + { id = "debug-statements" } +] + +[[repos]] +repo = "https://github.com/astral-sh/ruff-pre-commit" +rev = "v0.14.11" +hooks = [ + { id = "ruff-check" }, + { id = "ruff-format" } +] + +[[repos]] +repo = "local" +hooks = [ + { + id = "lint-rust", + name = "Lint Rust", + entry = "make lint-rust", + types = ["rust"], + language = "rust", + pass_filenames = false + } +] diff --git a/pyproject.toml b/pyproject.toml index 03ccdeb7..00cac93e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ pygments = "^2.2" markdown-include = "^0.8.1" [tool.poetry.group.lint.dependencies] -pre-commit = "^3.0.0" +prek = ">=0.3.4" [tool.poetry.group.typing.dependencies] mypy = "^1.3.0"