diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cca97a338..092c670c2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,7 +13,7 @@ // Allow X11 apps to run inside the container "DISPLAY": "${localEnv:DISPLAY}", // Put things that allow it in the persistent cache - "PRE_COMMIT_HOME": "/cache/pre-commit", + "PREK_HOME": "/cache/prek", "UV_CACHE_DIR": "/cache/uv", "UV_PYTHON_CACHE_DIR": "/cache/uv-python", // Make a venv that is specific for this workspace path as the cache is shared @@ -64,7 +64,7 @@ "target": "/user-terminal-config", "type": "bind" }, - // Keep a persistent cross container cache for uv, pre-commit, and the venvs + // Keep a persistent cross container cache for uv, prek, and the venvs { "source": "devcontainer-shared-cache", "target": "/cache", @@ -73,6 +73,6 @@ ], // Mount the parent as /workspaces so we can pip install peers as editable "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", - // After the container is created, recreate the venv then make pre-commit first run faster - "postCreateCommand": "uv venv --clear && uv sync && pre-commit install --install-hooks" + // After the container is created, recreate the venv then make prek first run faster + "postCreateCommand": "uv venv --clear && uv sync && prek install --install-hooks" } diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 320976f4a..000000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,55 +0,0 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: check-added-large-files - exclude: ^uv.lock - - id: check-yaml - exclude: ^helm/blueapi/templates/ - args: [--allow-multiple-documents] - - id: check-merge-conflict - - id: end-of-file-fixer - - - repo: local - hooks: - - id: ruff - name: lint with ruff - language: system - entry: ruff check --force-exclude --fix - types: [python] - require_serial: true - - - id: ruff-format - name: format with ruff - language: system - entry: ruff format --force-exclude - types: [python] - require_serial: true - - - id: uv-sync - name: update uv.lock and venv - pass_filenames: false - language: system - entry: uv sync - files: ^(uv\.lock|pyproject\.toml)$ - - - repo: https://github.com/norwoodj/helm-docs - rev: "v1.14.2" - hooks: - - id: helm-docs-built - args: - # Make the tool search for charts only under the `helm` directory - - --chart-search-root=helm - - - repo: https://github.com/losisin/helm-values-schema-json - rev: v2.3.1 - hooks: - - id: helm-schema - args: - - "--config" - - "helm/blueapi/.schema.yaml" - - - repo: https://github.com/gitleaks/gitleaks - rev: v8.28.0 - hooks: - - id: gitleaks diff --git a/prek.toml b/prek.toml new file mode 100644 index 000000000..164d9bec9 --- /dev/null +++ b/prek.toml @@ -0,0 +1,45 @@ +[[repos]] +repo = "builtin" +hooks = [ + { id = "check-added-large-files", exclude = "^uv.lock$" }, + { + id = "check-yaml", + exclude = "^helm/blueapi/templates", + args = ["--allow-multiple-documents"] + }, + { id = "check-merge-conflict" }, + { id = "end-of-file-fixer" }, + { id = "no-commit-to-branch" } +] + +[[repos]] +repo = "https://github.com/astral-sh/ruff-pre-commit" +rev = "v0.15.1" +hooks = [ + { id = "ruff-check", args = ["--fix"] }, + { id = "ruff-format" }, +] + +[[repos]] +repo = "https://github.com/astral-sh/uv-pre-commit" +rev = "0.10.2" +hooks = [ + { id = "uv-sync", args = [] }, +] + +[[repos]] +repo = "https://github.com/norwoodj/helm-docs" +rev = "v1.14.2" +hooks = [{ id = "helm-docs-built", args = ["--chart-search-root=helm"] }] + +[[repos]] +repo = "https://github.com/losisin/helm-values-schema-json" +rev = "v2.3.1" +hooks = [ + { id = "helm-schema", args = ["--config", "helm/blueapi/.schema.yaml"] } +] + +[[repos]] +repo = "https://github.com/gitleaks/gitleaks" +rev = "v8.28.0" +hooks = [{ id = "gitleaks" }] diff --git a/pyproject.toml b/pyproject.toml index dda9611ea..5b66cc1ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ requires-python = ">=3.11" dev = [ "copier", "myst-parser", - "pre-commit", + "prek", "pydata-sphinx-theme>=0.15.4", "pytest", "pyright!=1.1.407", # https://github.com/bluesky/scanspec/issues/190 @@ -119,10 +119,12 @@ env_list = ["pre-commit", "type-checking", "tests", "docs"] passenv = ["*"] [tool.tox.env.pre-commit] -description = "Run pre-commit on all files" +description = "Run pre-commit (prek) on all files" commands = [ [ - "pre-commit", + "uv", + "run", + "prek", "run", "--all-files", "--show-diff-on-failure", diff --git a/uv.lock b/uv.lock index 1eb18bb2a..5893150fc 100644 --- a/uv.lock +++ b/uv.lock @@ -451,7 +451,7 @@ dev = [ { name = "jwcrypto" }, { name = "mock" }, { name = "myst-parser" }, - { name = "pre-commit" }, + { name = "prek" }, { name = "pydata-sphinx-theme" }, { name = "pyright" }, { name = "pytest" }, @@ -507,7 +507,7 @@ dev = [ { name = "jwcrypto" }, { name = "mock" }, { name = "myst-parser" }, - { name = "pre-commit" }, + { name = "prek" }, { name = "pydata-sphinx-theme", specifier = ">=0.15.4" }, { name = "pyright", specifier = "!=1.1.407" }, { name = "pytest" }, @@ -668,15 +668,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ae/3a/dbeec9d1ee0844c679f6bb5d6ad4e9f198b1224f4e7a32825f47f6192b0c/cffi-2.0.0-cp314-cp314t-win_arm64.whl", hash = "sha256:0a1527a803f0a659de1af2e1fd700213caba79377e27e4693648c2923da066f9", size = 184195, upload-time = "2025-09-08T23:23:43.004Z" }, ] -[[package]] -name = "cfgv" -version = "3.5.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/4e/b5/721b8799b04bf9afe054a3899c6cf4e880fcf8563cc71c15610242490a0c/cfgv-3.5.0.tar.gz", hash = "sha256:d5b1034354820651caa73ede66a6294d6e95c1b00acc5e9b098e917404669132", size = 7334, upload-time = "2025-11-19T20:55:51.612Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/db/3c/33bac158f8ab7f89b2e59426d5fe2e4f63f7ed25df84c036890172b412b5/cfgv-3.5.0-py2.py3-none-any.whl", hash = "sha256:a8dc6b26ad22ff227d2634a65cb388215ce6cc96bbcc5cfde7641ae87e8dacc0", size = 7445, upload-time = "2025-11-19T20:55:50.744Z" }, -] - [[package]] name = "chardet" version = "5.2.0" @@ -2032,15 +2023,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, ] -[[package]] -name = "identify" -version = "2.6.16" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/5b/8d/e8b97e6bd3fb6fb271346f7981362f1e04d6a7463abd0de79e1fda17c067/identify-2.6.16.tar.gz", hash = "sha256:846857203b5511bbe94d5a352a48ef2359532bc8f6727b5544077a0dcfb24980", size = 99360, upload-time = "2026-01-12T18:58:58.201Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/b8/58/40fbbcefeda82364720eba5cf2270f98496bdfa19ea75b4cccae79c698e6/identify-2.6.16-py2.py3-none-any.whl", hash = "sha256:391ee4d77741d994189522896270b787aed8670389bfd60f326d677d64a6dfb0", size = 99202, upload-time = "2026-01-12T18:58:56.627Z" }, -] - [[package]] name = "idna" version = "3.11" @@ -3686,19 +3668,27 @@ wheels = [ ] [[package]] -name = "pre-commit" -version = "4.5.1" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "cfgv" }, - { name = "identify" }, - { name = "nodeenv" }, - { name = "pyyaml" }, - { name = "virtualenv" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/40/f1/6d86a29246dfd2e9b6237f0b5823717f60cad94d47ddc26afa916d21f525/pre_commit-4.5.1.tar.gz", hash = "sha256:eb545fcff725875197837263e977ea257a402056661f09dae08e4b149b030a61", size = 198232, upload-time = "2025-12-16T21:14:33.552Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/5d/19/fd3ef348460c80af7bb4669ea7926651d1f95c23ff2df18b9d24bab4f3fa/pre_commit-4.5.1-py2.py3-none-any.whl", hash = "sha256:3b3afd891e97337708c1674210f8eba659b52a38ea5f822ff142d10786221f77", size = 226437, upload-time = "2025-12-16T21:14:32.409Z" }, +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]]