From d18c147ed2cfda6b538a39b75eb9ea90022b3305 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 23 Nov 2026 10:03:29 -0800 Subject: [PATCH] chore(dev): replace pre-commit with prek pre-commit pulls virtualenv and its command-injection advisories into the dev lock. prek is pre-commit-compatible and manages hook environments with uv, so virtualenv and its transitive dependencies drop out entirely. --- .github/workflows/ci.yml | 24 ++++----- .pre-commit-config.yaml | 3 +- clients/python/pyproject.toml | 2 +- devenv/sync.py | 4 +- integration_tests/pyproject.toml | 2 +- pyproject.toml | 5 +- uv.lock | 87 +++++++------------------------- 7 files changed, 38 insertions(+), 89 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8d3e44b..ec988cbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,21 +64,21 @@ jobs: - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: - path: ~/.cache/pre-commit + path: ~/.cache/prek key: cache-epoch-1|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml', 'uv.lock') }} - - name: Install pre-commit - run: pre-commit install-hooks + - name: Install prek + run: .venv/bin/prek prepare-hooks - - name: Run pre-commit + - name: Run prek run: | if [ "${{ github.event_name }}" = "push" ]; then # On main branch, run on all files to catch any formatting drift - pre-commit run --all-files + .venv/bin/prek run --all-files else # On PRs, run only on changed files jq '.[]' --raw-output <<< '${{steps.changes.outputs.all_files}}' | - xargs pre-commit run --files + xargs .venv/bin/prek run --files fi python-client-lint: @@ -98,7 +98,7 @@ jobs: - name: Skip if no Python client changes if: steps.changes.outputs.python != 'true' - run: echo "No Python client files changed, skipping pre-commit checks" + run: echo "No Python client files changed, skipping prek checks" - uses: astral-sh/setup-uv@5a7eac68fb9809dea845d802897dc5c723910fa3 # v7.1.3 if: steps.changes.outputs.python == 'true' @@ -115,18 +115,18 @@ jobs: - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 if: steps.changes.outputs.python == 'true' with: - path: ~/.cache/pre-commit + path: ~/.cache/prek key: cache-epoch-1|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml', 'uv.lock') }} - - name: Install pre-commit + - name: Install prek if: steps.changes.outputs.python == 'true' - run: pre-commit install-hooks + run: .venv/bin/prek prepare-hooks - - name: Run pre-commit on Python client files + - name: Run prek on Python client files if: steps.changes.outputs.python == 'true' run: | jq '.[]' --raw-output <<< '${{steps.changes.outputs.python_files}}' | - xargs pre-commit run --files + xargs .venv/bin/prek run --files python-client-test: name: Python Client Tests diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ffdda524..0be2ddd3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,5 @@ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 +- repo: builtin hooks: - id: check-case-conflict - id: check-executables-have-shebangs diff --git a/clients/python/pyproject.toml b/clients/python/pyproject.toml index 6c1af48a..a7878d68 100644 --- a/clients/python/pyproject.toml +++ b/clients/python/pyproject.toml @@ -23,7 +23,7 @@ dev = [ "devservices>=1.2.1", "sentry-devenv>=1.22.2", "black==26.10.1", - "pre-commit>=4.2.0", + "prek>=0.5.10", "pytest>=8.3.3", "pytest-cov>=4.0.0", "flake8>=7.3.0", diff --git a/devenv/sync.py b/devenv/sync.py index 84d07df4..a4129ffd 100644 --- a/devenv/sync.py +++ b/devenv/sync.py @@ -37,7 +37,7 @@ def main(context: dict[str, str]) -> int: ), ) - print("installing pre-commit hooks ...") - proc.run((f"{reporoot}/.venv/bin/pre-commit", "install", "--install-hooks")) + print("installing prek hooks ...") + proc.run((f"{reporoot}/.venv/bin/prek", "install", "--prepare-hooks", "-f")) return 0 diff --git a/integration_tests/pyproject.toml b/integration_tests/pyproject.toml index cc7ef26b..7366f7f9 100644 --- a/integration_tests/pyproject.toml +++ b/integration_tests/pyproject.toml @@ -8,7 +8,7 @@ version = "0.0.0" dev = [ "black==26.10.1", "devservices>=1.2.1", - "pre-commit>=4.2.0", + "prek>=0.5.10", "pytest>=8.3.3", "sentry-devenv>=1.22.2", "confluent_kafka>=2.3.0", diff --git a/pyproject.toml b/pyproject.toml index 2193aee2..c7ad4ae9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ requires-python = ">=3.11" dev = [ "black==26.10.1", "devservices>=1.2.1", - "pre-commit>=4.2.0", + "prek>=0.5.10", "pytest>=9.0.3", "sentry-devenv>=1.22.2", "confluent_kafka>=2.3.0", @@ -29,6 +29,9 @@ dev = [ [tool.uv] environments = ["sys_platform == 'darwin' or sys_platform == 'linux'"] +[tool.uv.sources] +prek = { index = "sfw" } + [[tool.uv.index]] name = "sentry-pypi" url = "https://pypi.devinfra.sentry.io/simple" diff --git a/uv.lock b/uv.lock index 01eb0df1..8e4e0118 100644 --- a/uv.lock +++ b/uv.lock @@ -72,14 +72,6 @@ wheels = [ { url = "https://pypi.devinfra.sentry.io/wheels/cffi-2.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:afb8db5439b81cf9c9d0c80404b60c3cc9c3add93e114dcae767f1477cb53775" }, ] -[[package]] -name = "cfgv" -version = "3.4.0" -source = { registry = "https://pypi.devinfra.sentry.io/simple" } -wheels = [ - { url = "https://pypi.devinfra.sentry.io/wheels/cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9" }, -] - [[package]] name = "charset-normalizer" version = "3.4.7" @@ -187,22 +179,6 @@ wheels = [ { url = "https://pypi.devinfra.sentry.io/wheels/devservices-1.2.1-py3-none-any.whl", hash = "sha256:7c76ab711550cd1f42bd99b12edfcbdb1792fb7df0b7fec51eb13a2e2ff5df1b" }, ] -[[package]] -name = "distlib" -version = "0.3.9" -source = { registry = "https://pypi.devinfra.sentry.io/simple" } -wheels = [ - { url = "https://pypi.devinfra.sentry.io/wheels/distlib-0.3.9-py2.py3-none-any.whl", hash = "sha256:47f8c22fd27c27e25a65601af709b38e4f0a45ea4fc2e710f65755fa8caaaf87" }, -] - -[[package]] -name = "filelock" -version = "3.20.3" -source = { registry = "https://pypi.devinfra.sentry.io/simple" } -wheels = [ - { url = "https://pypi.devinfra.sentry.io/wheels/filelock-3.20.3-py3-none-any.whl", hash = "sha256:4b0dda527ee31078689fc205ec4f1c1bf7d56cf88b6dc9426c4f230e46c2dce1" }, -] - [[package]] name = "flake8" version = "7.3.0" @@ -314,14 +290,6 @@ wheels = [ { url = "https://pypi.devinfra.sentry.io/wheels/hyperframe-6.1.0-py3-none-any.whl", hash = "sha256:b03380493a519fce58ea5af42e4a42317bf9bd425596f7a0835ffce80f1a42e5" }, ] -[[package]] -name = "identify" -version = "2.6.9" -source = { registry = "https://pypi.devinfra.sentry.io/simple" } -wheels = [ - { url = "https://pypi.devinfra.sentry.io/wheels/identify-2.6.9-py2.py3-none-any.whl", hash = "sha256:c98b4322da415a8e5a70ff6e51fbc2d2932c015532d77e9f8537b4ba7813b150" }, -] - [[package]] name = "idna" version = "3.17" @@ -408,14 +376,6 @@ wheels = [ { url = "https://pypi.devinfra.sentry.io/wheels/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505" }, ] -[[package]] -name = "nodeenv" -version = "1.9.1" -source = { registry = "https://pypi.devinfra.sentry.io/simple" } -wheels = [ - { url = "https://pypi.devinfra.sentry.io/wheels/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9" }, -] - [[package]] name = "orjson" version = "3.11.6" @@ -468,18 +428,18 @@ wheels = [ ] [[package]] -name = "pre-commit" -version = "4.2.0" -source = { registry = "https://pypi.devinfra.sentry.io/simple" } -dependencies = [ - { name = "cfgv" }, - { name = "identify" }, - { name = "nodeenv" }, - { name = "pyyaml" }, - { name = "virtualenv" }, -] +name = "prek" +version = "0.5.11" +source = { registry = "https://sfw.security.sentry.io/pypi/simple" } +sdist = { url = "https://sfw.security.sentry.io/pypi/packages/19/0d/8f661ef91334d8afe883a51f586628bb0a18c5077b39dc7c2754bc5335da/prek-0.5.11.tar.gz", hash = "sha256:99c8363ca07b881dc49cf71eb3c362670c95d0d554fc375ceee0245548081829", size = 619436, upload-time = "2026-11-16T06:42:02.693Z" } wheels = [ - { url = "https://pypi.devinfra.sentry.io/wheels/pre_commit-4.2.0-py2.py3-none-any.whl", hash = "sha256:a009ca7205f1eb497d10b845e52c838a98b6cdd2102a6c8e4540e94ee75c58bd" }, + { url = "https://sfw.security.sentry.io/pypi/packages/26/33/b56b4898fe9a81e250d31e39cce0ae5705ee07609aa5f013cd22cfd781bc/prek-0.5.11-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:95da482d8f1d3323beea219e95b6bbe31a27d3b14943148d3c4eac94e9f7d7ee", size = 5916762, upload-time = "2026-11-16T06:41:46.081Z" }, + { url = "https://sfw.security.sentry.io/pypi/packages/ad/24/ef97844954e5a89c79de675d22fad0aa549db21c32226dde4a12eef5da6b/prek-0.5.11-py3-none-macosx_11_0_arm64.whl", hash = "sha256:2e530bd4c8975c6ac6eae20c70fa54c50714d56279040cc3c2b0bce279c0c84e", size = 5565126, upload-time = "2026-11-16T06:41:48.031Z" }, + { url = "https://sfw.security.sentry.io/pypi/packages/15/53/57e487d315e1fe7b1b11b1df01233f3c9cda14502f61ba76c34991d80358/prek-0.5.11-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:1cce91fe6524e1b2dfc4e5f40353caa0b62e2db9ae4b2bab314958027663a712", size = 5699656, upload-time = "2026-11-16T06:41:49.768Z" }, + { url = "https://sfw.security.sentry.io/pypi/packages/19/25/96988fbaf7bb960028fc4161ed734d0950bfda720c37206b3c6d07e044c4/prek-0.5.11-py3-none-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:c343b4e40e5aa5851fd0526c49ad8f52c4c688cde848fa95f57db91c15c67215", size = 6130515, upload-time = "2026-11-16T06:41:51.727Z" }, + { url = "https://sfw.security.sentry.io/pypi/packages/02/f0/35e94ecd6eab935705e68cfb33af06d27db4693a49214171a9adfcecb756/prek-0.5.11-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ca78936abfb2793ba9d6b9b4ac0e4eb13189bcfabd16d94c29aa573963bac87f", size = 5991609, upload-time = "2026-11-16T06:41:53.625Z" }, + { url = "https://sfw.security.sentry.io/pypi/packages/f9/44/a63b178a08d5bca1f4cfdef7305344195015fb6d5ff19be514b3a8a24f52/prek-0.5.11-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:c90b274d8eb35f28d6b70907b9d757072e20dccde1bdb7d19eeb85aac9c37ee3", size = 5682010, upload-time = "2026-11-16T06:41:55.592Z" }, + { url = "https://sfw.security.sentry.io/pypi/packages/f2/d6/0c8f2770bf03408e6c35ebea6e858d2f33d0e4037562a8f6092f73fd4223/prek-0.5.11-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:e5cbd96ed40c04a7909d98a9b8cd1d38e8e63d52e97932f09e1733b9f51bd6ac", size = 6146351, upload-time = "2026-11-16T06:41:57.479Z" }, ] [[package]] @@ -760,7 +720,7 @@ dev = [ { name = "isort" }, { name = "mypy" }, { name = "orjson" }, - { name = "pre-commit" }, + { name = "prek" }, { name = "protobuf" }, { name = "psycopg2-binary" }, { name = "pytest" }, @@ -783,7 +743,7 @@ dev = [ { name = "isort", specifier = ">=5.13.2" }, { name = "mypy", specifier = ">=1.17.1" }, { name = "orjson", specifier = ">=3.10.10" }, - { name = "pre-commit", specifier = ">=4.2.0" }, + { name = "prek", specifier = ">=0.5.10", index = "https://sfw.security.sentry.io/pypi/simple" }, { name = "protobuf", specifier = ">=5.28.3" }, { name = "psycopg2-binary", specifier = ">=2.9" }, { name = "pytest", specifier = ">=9.0.3" }, @@ -833,7 +793,7 @@ dev = [ { name = "flake8" }, { name = "isort" }, { name = "mypy" }, - { name = "pre-commit" }, + { name = "prek" }, { name = "pytest" }, { name = "pytest-cov" }, { name = "sentry-devenv" }, @@ -870,7 +830,7 @@ dev = [ { name = "flake8", specifier = ">=7.3.0" }, { name = "isort", specifier = ">=5.13.2" }, { name = "mypy", specifier = ">=1.17.1" }, - { name = "pre-commit", specifier = ">=4.2.0" }, + { name = "prek", specifier = ">=0.5.10", index = "https://sfw.security.sentry.io/pypi/simple" }, { name = "pytest", specifier = ">=8.3.3" }, { name = "pytest-cov", specifier = ">=4.0.0" }, { name = "sentry-devenv", specifier = ">=1.22.2" }, @@ -893,7 +853,7 @@ dev = [ { name = "isort" }, { name = "mypy" }, { name = "orjson" }, - { name = "pre-commit" }, + { name = "prek" }, { name = "protobuf" }, { name = "psycopg2-binary" }, { name = "pytest" }, @@ -916,7 +876,7 @@ dev = [ { name = "isort", specifier = ">=5.13.2" }, { name = "mypy", specifier = ">=1.17.1" }, { name = "orjson", specifier = ">=3.10.10" }, - { name = "pre-commit", specifier = ">=4.2.0" }, + { name = "prek", specifier = ">=0.5.10", index = "https://sfw.security.sentry.io/pypi/simple" }, { name = "protobuf", specifier = ">=5.28.3" }, { name = "psycopg2-binary", specifier = ">=2.9" }, { name = "pytest", specifier = ">=8.3.3" }, @@ -1004,19 +964,6 @@ wheels = [ { url = "https://pypi.devinfra.sentry.io/wheels/urllib3-2.8.0-py3-none-any.whl", hash = "sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3" }, ] -[[package]] -name = "virtualenv" -version = "20.36.1" -source = { registry = "https://pypi.devinfra.sentry.io/simple" } -dependencies = [ - { name = "distlib" }, - { name = "filelock" }, - { name = "platformdirs" }, -] -wheels = [ - { url = "https://pypi.devinfra.sentry.io/wheels/virtualenv-20.36.1-py3-none-any.whl", hash = "sha256:575a8d6b124ef88f6f51d56d656132389f961062a9177016a50e4f507bbcc19f" }, -] - [[package]] name = "zstandard" version = "0.18.0"