pre-commit-uv 4.4.3__tar.gz → 4.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ node: 3e6d0578f36c3c8883d91215ea8e840204a7043c
@@ -2,6 +2,26 @@
2
2
 
3
3
  <!-- towncrier release notes start -->
4
4
 
5
+ <a name="release-4-4-4"></a>
6
+
7
+ ## 4.4.4 (2026-12-06)
8
+
9
+ <a name="release-4-4-4-fixed"></a>
10
+
11
+ ### Fixed
12
+
13
+ - Accept hook environments built on a pre-release Python (such as `3.15.0rc1`): the health check compared uv's
14
+ `version_info` with a version that dropped the pre-release tag, so pre-commit stopped with "expected environment for
15
+ python to be healthy immediately after install" ([#240](https://github.com/tox-dev/pre-commit-uv/pull/240)) by
16
+ [@vinilpolepalli](https://github.com/vinilpolepalli) and [@gaborbernat](https://github.com/gaborbernat).
17
+
18
+ <a name="release-4-4-4-performance"></a>
19
+
20
+ ### Performance
21
+
22
+ - Reduce Python startup time and memory use when pre-commit-uv is installed on Python 3.15
23
+ ([#228](https://github.com/tox-dev/pre-commit-uv/pull/228)) by [@gaborbernat](https://github.com/gaborbernat).
24
+
5
25
  <a name="release-4-4-3"></a>
6
26
 
7
27
  ## 4.4.3 (2026-11-18)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pre-commit-uv
3
- Version: 4.4.3
3
+ Version: 4.4.4
4
4
  Import-Name: pre_commit_uv
5
5
  Summary: Run pre-commit with uv
6
6
  Project-URL: Bug Tracker, https://github.com/tox-dev/pre-commit-uv/issues
@@ -2,6 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ __lazy_modules__ = [
6
+ "pathlib",
7
+ ]
8
+
5
9
  # only import built-ins at top level to avoid interpreter startup overhead
6
10
  import os
7
11
  import pathlib
@@ -32,16 +36,11 @@ def patch() -> None:
32
36
 
33
37
  _ORIGINAL_MAIN, main.main = main.main, _new_main # ty: ignore[invalid-assignment] pre-commit exposes main as a plain function we patch on purpose
34
38
  if "--version" in sys.argv:
35
- from importlib.metadata import version as _metadata_version # ruff:ignore[import-outside-top-level] loaded only when pre-commit runs, keeping startup cheap
39
+ from importlib.metadata import version # ruff:ignore[import-outside-top-level] loaded only when pre-commit runs, keeping startup cheap
36
40
 
37
41
  from pre_commit import constants # ruff:ignore[import-outside-top-level] loaded only when pre-commit runs, keeping startup cheap
38
42
 
39
- constants.VERSION = (
40
- f"{constants.VERSION} ("
41
- f"pre-commit-uv={_metadata_version('pre-commit-uv')}, "
42
- f"uv={_metadata_version('uv')}"
43
- f")"
44
- )
43
+ constants.VERSION = f"{constants.VERSION} (pre-commit-uv={version('pre-commit-uv')}, uv={version('uv')})"
45
44
 
46
45
 
47
46
  def _is_calling_pre_commit() -> bool:
@@ -117,15 +116,15 @@ def _new_main(argv: Sequence[str] | None = None) -> int:
117
116
 
118
117
  @cache
119
118
  def self_version() -> str:
120
- from importlib.metadata import version as _metadata_version # ruff:ignore[import-outside-top-level] loaded only when pre-commit runs, keeping startup cheap
119
+ from importlib.metadata import version # ruff:ignore[import-outside-top-level] loaded only when pre-commit runs, keeping startup cheap
121
120
 
122
- return _metadata_version("pre-commit-uv")
121
+ return version("pre-commit-uv")
123
122
 
124
123
  @cache
125
124
  def uv_version() -> str:
126
- from importlib.metadata import version as _metadata_version # ruff:ignore[import-outside-top-level] loaded only when pre-commit runs, keeping startup cheap
125
+ from importlib.metadata import version # ruff:ignore[import-outside-top-level] loaded only when pre-commit runs, keeping startup cheap
127
126
 
128
- return _metadata_version("uv")
127
+ return version("uv")
129
128
 
130
129
  patched = cast("_PatchablePython", python)
131
130
  patched.install_environment = _install_environment
@@ -166,9 +165,9 @@ def _health_check(prefix: Prefix, version: str) -> str | None:
166
165
  def _version_info(exe: str) -> str:
167
166
  from pre_commit.util import CalledProcessError, cmd_output # ruff:ignore[import-outside-top-level] loaded only when pre-commit runs, keeping startup cheap
168
167
 
169
- prog = 'import sys;print(".".join(str(p) for p in sys.version_info[0:3]))'
170
168
  try:
171
- return cmd_output(exe, "-S", "-c", prog)[1].strip()
169
+ # uv writes this string as version_info: a pre-release keeps its tag (3.15.0rc1), a local build loses its "+"
170
+ return cmd_output(exe, "-S", "-c", 'import platform;print(platform.python_version().rstrip("+"))')[1].strip()
172
171
  except CalledProcessError:
173
172
  return f"<<error retrieving version from {exe}>>"
174
173
 
@@ -225,6 +225,27 @@ def test_health_check_full_version_passes(tmp_path: Path) -> None:
225
225
  assert python.health_check(prefix, _VERSION) is None
226
226
 
227
227
 
228
+ @pytest.mark.skipif(sys.platform == "win32", reason="the stand-in interpreter is a shebang script")
229
+ @pytest.mark.usefixtures("patched_pre_commit")
230
+ def test_health_check_pre_release_version_passes(tmp_path: Path) -> None:
231
+ # uv writes platform.python_version() for an interpreter it does not manage, so a pre-release keeps its tag
232
+ prefix = _make_env(tmp_path, "version_info = 3.16.0a2\n")
233
+ python_exe = tmp_path / python.bin_dir(str(tmp_path / f"py_env-{_VERSION}")) / "python"
234
+ python_exe.unlink()
235
+ pre_release = sys.version.replace(sys.version.split()[0], "3.16.0a2", 1)
236
+ python_exe.write_text(
237
+ dedent(f"""\
238
+ #!{sys.executable}
239
+ import sys
240
+ sys.version, sys.version_info = {pre_release!r}, (3, 16, 0, "alpha", 2)
241
+ exec(sys.argv[-1])
242
+ """)
243
+ )
244
+ python_exe.chmod(0o755)
245
+
246
+ assert python.health_check(prefix, _VERSION) is None
247
+
248
+
228
249
  @pytest.mark.usefixtures("patched_pre_commit")
229
250
  def test_health_check_no_base_executable_passes(tmp_path: Path) -> None:
230
251
  prefix = _make_env(tmp_path, f"version_info = {_MAJOR_MINOR}\n")
@@ -1 +0,0 @@
1
- node: ad57e53c5c59c60107180e8a1500190300359b71
File without changes
File without changes
File without changes
File without changes