From f1257eb373e8c957e7c9318d65e9d8d37315caba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 May 2026 20:24:39 +0000 Subject: [PATCH 1/6] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-mypy: v1.20.2 → v2.0.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.20.2...v2.0.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8b5347dfc..dcbe195e8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.20.2 + rev: v2.0.0 hooks: - id: mypy additional_dependencies: [types-pyyaml] From c68bd9c22eb6f27d967ccb8051e10cf0182993e5 Mon Sep 17 00:00:00 2001 From: anthony sottile Date: Tue, 12 May 2026 14:33:48 -0400 Subject: [PATCH 2/6] bash on windows-latest now reports cygwin --- testing/get-coursier.sh | 2 +- testing/get-dart.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/get-coursier.sh b/testing/get-coursier.sh index 958e73b24..0087feb82 100755 --- a/testing/get-coursier.sh +++ b/testing/get-coursier.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -if [ "$OSTYPE" = msys ]; then +if [ "$OSTYPE" = cygwin ]; then URL='https://github.com/coursier/coursier/releases/download/v2.1.0-RC4/cs-x86_64-pc-win32.zip' SHA256='0d07386ff0f337e3e6264f7dde29d137dda6eaa2385f29741435e0b93ccdb49d' TARGET='/tmp/coursier/cs.zip' diff --git a/testing/get-dart.sh b/testing/get-dart.sh index b4545e71e..ad7f8608a 100755 --- a/testing/get-dart.sh +++ b/testing/get-dart.sh @@ -3,7 +3,7 @@ set -euo pipefail VERSION=2.19.6 -if [ "$OSTYPE" = msys ]; then +if [ "$OSTYPE" = cygwin ]; then URL="https://storage.googleapis.com/dart-archive/channels/stable/release/${VERSION}/sdk/dartsdk-windows-x64-release.zip" cygpath -w /tmp/dart-sdk/bin >> "$GITHUB_PATH" else From 7154c807cc6e210b5b574baaeeb8837864f9a42f Mon Sep 17 00:00:00 2001 From: Al Sutton Date: Fri, 15 May 2026 10:35:13 +0100 Subject: [PATCH 3/6] Skip any tests that required rust to be installed when it isn't available --- tests/languages/rust_test.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/languages/rust_test.py b/tests/languages/rust_test.py index 52e356134..139420ff5 100644 --- a/tests/languages/rust_test.py +++ b/tests/languages/rust_test.py @@ -13,6 +13,12 @@ ACTUAL_GET_DEFAULT_VERSION = rust.get_default_version.__wrapped__ +def requires_locally_installed_cargo(): + return pytest.mark.skipif( + parse_shebang.find_executable('cargo') is None, + reason = "Cargo is not installed in the local environment" + ) + @pytest.fixture def cmd_output_b_mck(): @@ -20,16 +26,19 @@ def cmd_output_b_mck(): yield mck +@requires_locally_installed_cargo() def test_sets_system_when_rust_is_available(cmd_output_b_mck): cmd_output_b_mck.return_value = (0, b'', b'') assert ACTUAL_GET_DEFAULT_VERSION() == 'system' +@requires_locally_installed_cargo() def test_uses_default_when_rust_is_not_available(cmd_output_b_mck): cmd_output_b_mck.return_value = (127, b'', b'error: not found') assert ACTUAL_GET_DEFAULT_VERSION() == C.DEFAULT +@requires_locally_installed_cargo() def test_selects_system_even_if_rust_toolchain_toml(tmp_path): toolchain_toml = '[toolchain]\nchannel = "wtf"\n' tmp_path.joinpath('rust-toolchain.toml').write_text(toolchain_toml) @@ -84,6 +93,7 @@ def test_language_version_with_rustup(tmp_path, version): assert ret == (0, b'Hello, world!\n') +@requires_locally_installed_cargo() @pytest.mark.parametrize('dep', ('cli:shellharden:4.2.0', 'cli:shellharden')) def test_rust_cli_additional_dependencies(tmp_path, dep): _make_local_repo(str(tmp_path)) @@ -102,6 +112,7 @@ def test_rust_cli_additional_dependencies(tmp_path, dep): assert ret == (0, b'echo "$hi"\n') +@requires_locally_installed_cargo() def test_run_lib_additional_dependencies(tmp_path): _make_hello_world(tmp_path) From 1105cef8fadc6c118632dd6394c9dea31e28b5ba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 May 2026 09:44:30 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/languages/rust_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/languages/rust_test.py b/tests/languages/rust_test.py index 139420ff5..e6513a464 100644 --- a/tests/languages/rust_test.py +++ b/tests/languages/rust_test.py @@ -13,10 +13,11 @@ ACTUAL_GET_DEFAULT_VERSION = rust.get_default_version.__wrapped__ + def requires_locally_installed_cargo(): return pytest.mark.skipif( parse_shebang.find_executable('cargo') is None, - reason = "Cargo is not installed in the local environment" + reason='Cargo is not installed in the local environment', ) From ba7cf87baa9dbd695702654eef25ba85bdf92cbf Mon Sep 17 00:00:00 2001 From: Al Sutton Date: Fri, 15 May 2026 11:43:51 +0100 Subject: [PATCH 5/6] Move assert to a skipIf to ensure it's skipped on platforms where it isn't supported --- tests/languages/rust_test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/languages/rust_test.py b/tests/languages/rust_test.py index e6513a464..60e814641 100644 --- a/tests/languages/rust_test.py +++ b/tests/languages/rust_test.py @@ -20,6 +20,12 @@ def requires_locally_installed_cargo(): reason='Cargo is not installed in the local environment', ) +def requires_locally_installed_rustup(): + return pytest.mark.skipif( + parse_shebang.find_executable('rustup') is None, + reason = "Cargo is not installed in the local environment" + ) + @pytest.fixture def cmd_output_b_mck(): @@ -83,10 +89,9 @@ def mck(exe, env=None): assert calls == ['rustup', 'rustup', 'cargo', 'hello_world'] assert ret == (0, b'Hello, world!\n') - +@requires_locally_installed_rustup() @pytest.mark.parametrize('version', (C.DEFAULT, '1.56.0')) def test_language_version_with_rustup(tmp_path, version): - assert parse_shebang.find_executable('rustup') is not None _make_hello_world(tmp_path) From 5de00ab8ac9d6e9d63ba428f41275cca3fbec87a Mon Sep 17 00:00:00 2001 From: Al Sutton Date: Fri, 15 May 2026 12:13:54 +0100 Subject: [PATCH 6/6] Use a permanent directory for RUSTUP_HOME rustup installs the toolchain in RUSTUP_HOME, so we need it to be a permanent directory, and not a temporary one. --- pre_commit/languages/rust.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_commit/languages/rust.py b/pre_commit/languages/rust.py index fd77a9d29..4c0a99baf 100644 --- a/pre_commit/languages/rust.py +++ b/pre_commit/languages/rust.py @@ -82,7 +82,7 @@ def _add_dependencies( def install_rust_with_toolchain(toolchain: str, envdir: str) -> None: with tempfile.TemporaryDirectory() as rustup_dir: - with envcontext((('CARGO_HOME', envdir), ('RUSTUP_HOME', rustup_dir))): + with envcontext((('CARGO_HOME', envdir), ('RUSTUP_HOME', envdir))): # acquire `rustup` if not present if parse_shebang.find_executable('rustup') is None: # We did not detect rustup and need to download it first.