pre-commit-uv 4.1.4__tar.gz → 4.2.0__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: pre-commit-uv
3
- Version: 4.1.4
3
+ Version: 4.2.0
4
4
  Summary: Run pre-commit with uv
5
5
  Project-URL: Bug Tracker, https://github.com/tox-dev/pre-commit-uv/issues
6
6
  Project-URL: Changelog, https://github.com/tox-dev/pre-commit-uv/releases
@@ -31,19 +31,19 @@ Classifier: License :: OSI Approved :: MIT License
31
31
  Classifier: Operating System :: OS Independent
32
32
  Classifier: Programming Language :: Python
33
33
  Classifier: Programming Language :: Python :: 3 :: Only
34
- Classifier: Programming Language :: Python :: 3.9
35
34
  Classifier: Programming Language :: Python :: 3.10
36
35
  Classifier: Programming Language :: Python :: 3.11
37
36
  Classifier: Programming Language :: Python :: 3.12
38
37
  Classifier: Programming Language :: Python :: 3.13
39
- Requires-Python: >=3.9
40
- Requires-Dist: pre-commit>=3.8
41
- Requires-Dist: uv>=0.4.7
38
+ Classifier: Programming Language :: Python :: 3.14
39
+ Requires-Python: >=3.10
40
+ Requires-Dist: pre-commit>=4.3
41
+ Requires-Dist: uv>=0.9.1
42
42
  Provides-Extra: testing
43
43
  Requires-Dist: covdefaults>=2.3; extra == 'testing'
44
- Requires-Dist: pytest-cov>=5; extra == 'testing'
45
- Requires-Dist: pytest-mock>=3.14; extra == 'testing'
46
- Requires-Dist: pytest>=8.3.2; extra == 'testing'
44
+ Requires-Dist: pytest-cov>=7; extra == 'testing'
45
+ Requires-Dist: pytest-mock>=3.15.1; extra == 'testing'
46
+ Requires-Dist: pytest>=8.4.2; extra == 'testing'
47
47
  Description-Content-Type: text/markdown
48
48
 
49
49
  # pre-commit-uv
@@ -1,8 +1,8 @@
1
1
  [build-system]
2
2
  build-backend = "hatchling.build"
3
3
  requires = [
4
- "hatch-vcs>=0.4",
5
- "hatchling>=1.25",
4
+ "hatch-vcs>=0.5",
5
+ "hatchling>=1.27",
6
6
  ]
7
7
 
8
8
  [project]
@@ -17,30 +17,30 @@ license.file = "LICENSE.txt"
17
17
  authors = [
18
18
  { name = "Bernat Gabor", email = "gaborjbernat@gmail.com" },
19
19
  ]
20
- requires-python = ">=3.9"
20
+ requires-python = ">=3.10"
21
21
  classifiers = [
22
22
  "License :: OSI Approved :: MIT License",
23
23
  "Operating System :: OS Independent",
24
24
  "Programming Language :: Python",
25
25
  "Programming Language :: Python :: 3 :: Only",
26
- "Programming Language :: Python :: 3.9",
27
26
  "Programming Language :: Python :: 3.10",
28
27
  "Programming Language :: Python :: 3.11",
29
28
  "Programming Language :: Python :: 3.12",
30
29
  "Programming Language :: Python :: 3.13",
30
+ "Programming Language :: Python :: 3.14",
31
31
  ]
32
32
  dynamic = [
33
33
  "version",
34
34
  ]
35
35
  dependencies = [
36
- "pre-commit>=3.8",
37
- "uv>=0.4.7",
36
+ "pre-commit>=4.3",
37
+ "uv>=0.9.1",
38
38
  ]
39
39
  optional-dependencies.testing = [
40
40
  "covdefaults>=2.3",
41
- "pytest>=8.3.2",
42
- "pytest-cov>=5",
43
- "pytest-mock>=3.14",
41
+ "pytest>=8.4.2",
42
+ "pytest-cov>=7",
43
+ "pytest-mock>=3.15.1",
44
44
  ]
45
45
  urls."Bug Tracker" = "https://github.com/tox-dev/pre-commit-uv/issues"
46
46
  urls."Changelog" = "https://github.com/tox-dev/pre-commit-uv/releases"
@@ -61,7 +61,6 @@ build.targets.wheel.sources = [ "src" ]
61
61
  version.source = "vcs"
62
62
 
63
63
  [tool.ruff]
64
- target-version = "py39"
65
64
  line-length = 120
66
65
  format.preview = true
67
66
  format.docstring-code-line-length = 100
@@ -103,7 +102,7 @@ builtin = "clear,usage,en-GB_to_en-US"
103
102
  count = true
104
103
 
105
104
  [tool.pyproject-fmt]
106
- max_supported_python = "3.13"
105
+ max_supported_python = "3.14"
107
106
 
108
107
  [tool.pytest]
109
108
  ini_options.testpaths = [
@@ -59,18 +59,40 @@ def _new_main(argv: list[str] | None = None) -> int:
59
59
  ) -> None:
60
60
  import logging # noqa: PLC0415
61
61
 
62
+ from pre_commit.git import get_root # noqa: PLC0415
62
63
  from pre_commit.lang_base import environment_dir, setup_cmd # noqa: PLC0415
63
64
  from pre_commit.util import cmd_output_b # noqa: PLC0415
64
65
 
66
+ project_root_dir = get_root()
67
+
65
68
  logger = logging.getLogger("pre_commit")
66
69
  logger.info("Using pre-commit with uv %s via pre-commit-uv %s", uv_version(), self_version())
67
70
  uv = _uv()
68
71
  py = python.norm_version(version) or os.environ.get("UV_PYTHON", sys.executable)
69
- venv_cmd = [uv, "venv", environment_dir(prefix, python.ENVIRONMENT_DIR, version), "-p", py]
72
+ venv_cmd = [
73
+ uv,
74
+ "--project",
75
+ project_root_dir,
76
+ "venv",
77
+ environment_dir(prefix, python.ENVIRONMENT_DIR, version),
78
+ "-p",
79
+ py,
80
+ ]
70
81
  cmd_output_b(*venv_cmd, cwd="/")
71
82
 
72
83
  with python.in_env(prefix, version):
73
- setup_cmd(prefix, (uv, "pip", "install", ".", *additional_dependencies))
84
+ setup_cmd(
85
+ prefix,
86
+ (
87
+ uv,
88
+ "--project",
89
+ project_root_dir,
90
+ "pip",
91
+ "install",
92
+ ".",
93
+ *additional_dependencies,
94
+ ),
95
+ )
74
96
 
75
97
  @cache
76
98
  def _uv() -> str:
@@ -96,11 +118,11 @@ def _new_main(argv: list[str] | None = None) -> int:
96
118
 
97
119
  prog = 'import sys;print(".".join(str(p) for p in sys.version_info[0:3]))'
98
120
  try:
99
- return cast(str, cmd_output(exe, "-S", "-c", prog)[1].strip())
121
+ return cast("str", cmd_output(exe, "-S", "-c", prog)[1].strip())
100
122
  except CalledProcessError:
101
123
  return f"<<error retrieving version from {exe}>>"
102
124
 
103
125
  python.install_environment = _install_environment
104
126
  python._version_info = _version_info # noqa: SLF001
105
127
  assert _original_main is not None # noqa: S101
106
- return cast(int, _original_main(argv))
128
+ return cast("int", _original_main(argv))
@@ -66,3 +66,97 @@ def test_install(git_repo: Path, caplog: pytest.LogCaptureFixture, monkeypatch:
66
66
  "This may take a few minutes...",
67
67
  f"Using pre-commit with uv {uv} via pre-commit-uv {self}",
68
68
  ]
69
+
70
+
71
+ test_install_with_uv_config_cases: list[tuple[str, str]] = [
72
+ (
73
+ "pyproject.toml",
74
+ """
75
+ [[tool.uv.index]]
76
+ name = "internal"
77
+ url = "https://pypi.org/simple/"
78
+ default = true
79
+ """,
80
+ ),
81
+ (
82
+ "uv.toml",
83
+ """
84
+ [[index]]
85
+ name = "internal"
86
+ url = "https://pypi.org/simple/"
87
+ default = true
88
+ """,
89
+ ),
90
+ ]
91
+
92
+
93
+ @pytest.mark.parametrize(
94
+ ("file_name", "content"),
95
+ test_install_with_uv_config_cases,
96
+ )
97
+ def test_install_with_uv_config(
98
+ git_repo: Path,
99
+ caplog: pytest.LogCaptureFixture,
100
+ monkeypatch: pytest.MonkeyPatch,
101
+ file_name: str,
102
+ content: str,
103
+ ) -> None:
104
+ (git_repo / file_name).write_text(dedent(content))
105
+
106
+ monkeypatch.setenv("FORCE_PRE_COMMIT_UV_PATCH", "1")
107
+
108
+ import pre_commit_uv # noqa: PLC0415
109
+
110
+ pre_commit_uv._patch() # noqa: SLF001
111
+ main.main(["install-hooks", "-c", str(git_repo / precommit_file)])
112
+
113
+ assert caplog.messages == [
114
+ "Initializing environment for https://github.com/tox-dev/pyproject-fmt.",
115
+ "Installing environment for https://github.com/tox-dev/pyproject-fmt.",
116
+ "Once installed this environment will be reused.",
117
+ "This may take a few minutes...",
118
+ f"Using pre-commit with uv {uv} via pre-commit-uv {self}",
119
+ ]
120
+
121
+
122
+ test_install_with_uv_config_raises_error_cases: list[tuple[str, str]] = [
123
+ (
124
+ "pyproject.toml",
125
+ """
126
+ [[tool.uv.index]]
127
+ name = "internal"
128
+ url = "https://pypi.example/simple/"
129
+ default = true
130
+ """,
131
+ ),
132
+ (
133
+ "uv.toml",
134
+ """
135
+ [[index]]
136
+ name = "internal"
137
+ url = "https://pypi.example/simple/"
138
+ default = true
139
+ """,
140
+ ),
141
+ ]
142
+
143
+
144
+ @pytest.mark.parametrize(("file_name", "content"), test_install_with_uv_config_raises_error_cases)
145
+ def test_install_with_uv_config_raises_error(
146
+ git_repo: Path,
147
+ monkeypatch: pytest.MonkeyPatch,
148
+ file_name: str,
149
+ content: str,
150
+ ) -> None:
151
+ """Test to make sure that uv config is used for non default pypi repos."""
152
+ (git_repo / file_name).write_text(dedent(content))
153
+
154
+ monkeypatch.setenv("FORCE_PRE_COMMIT_UV_PATCH", "1")
155
+
156
+ import pre_commit_uv # noqa: PLC0415
157
+
158
+ pre_commit_uv._patch() # noqa: SLF001
159
+
160
+ # would raise SystemExit due to bad config
161
+ with pytest.raises(SystemExit):
162
+ main.main(["install-hooks", "-c", str(git_repo / precommit_file)])
@@ -1,9 +1,10 @@
1
1
  [tox]
2
2
  requires =
3
- tox>=4.2
4
- tox-uv>=1.11.3
3
+ tox>=4.31
4
+ tox-uv>=1.28.1
5
5
  env_list =
6
6
  fix
7
+ 3.14
7
8
  3.13
8
9
  3.12
9
10
  3.11
@@ -43,7 +44,7 @@ commands =
43
44
  [testenv:type]
44
45
  description = run type check on code base
45
46
  deps =
46
- mypy==1.11.2
47
+ mypy==1.18.2
47
48
  commands =
48
49
  mypy src
49
50
  mypy tests
@@ -52,9 +53,9 @@ commands =
52
53
  description = check that the long description is valid
53
54
  skip_install = true
54
55
  deps =
55
- check-wheel-contents>=0.6
56
- twine>=5.1.1
57
- uv>=0.4.10
56
+ check-wheel-contents>=0.6.3
57
+ twine>=6.2
58
+ uv>=0.9.1
58
59
  commands =
59
60
  uv build --sdist --wheel --out-dir {env_tmp_dir} .
60
61
  twine check {env_tmp_dir}{/}*
File without changes
File without changes
File without changes