dycw-pre-commit-hooks 0.9.23__py3-none-any.whl → 0.9.26__py3-none-any.whl

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.

Potentially problematic release.


This version of dycw-pre-commit-hooks might be problematic. Click here for more details.

@@ -1,17 +1,18 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: dycw-pre-commit-hooks
3
- Version: 0.9.23
3
+ Version: 0.9.26
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  Requires-Python: >=3.11
6
- Requires-Dist: click<8.2,>=8.1.7
7
- Requires-Dist: dycw-utilities<0.59,>=0.58.16
8
- Requires-Dist: loguru<0.8,>=0.7.2
9
- Requires-Dist: semver<3.1,>=3.0.2
6
+ Requires-Dist: click<8.2,>=8.1.8
7
+ Requires-Dist: dycw-utilities<0.95,>=0.94.13
8
+ Requires-Dist: loguru<0.8,>=0.7.3
9
+ Requires-Dist: semver<3.1,>=3.0.4
10
10
  Requires-Dist: tomlkit<0.14,>=0.13.2
11
- Requires-Dist: xdg-base-dirs<6.1,>=6.0.1
11
+ Requires-Dist: xdg-base-dirs<6.1,>=6.0.2
12
12
  Provides-Extra: dev
13
13
  Requires-Dist: dycw-utilities[test]; extra == 'dev'
14
- Requires-Dist: hatch<1.13,>=1.12.0; extra == 'dev'
14
+ Requires-Dist: hatch<1.15,>=1.14.0; extra == 'dev'
15
+ Requires-Dist: setuptools<75.9,>=75.8.1; extra == 'dev'
15
16
  Description-Content-Type: text/markdown
16
17
 
17
18
  # pre-commit-hooks
@@ -1,4 +1,4 @@
1
- pre_commit_hooks/__init__.py,sha256=XqHE2wjGGjB2zQd-Wmg-_aAfxyq-YNrUSyrIvB-Lvjk,59
1
+ pre_commit_hooks/__init__.py,sha256=68T9JoCN9uQzWrP8Ll6vLywDeELNVauiOV-1k1JLvg4,59
2
2
  pre_commit_hooks/common.py,sha256=H8RJkUXKQ7vHbCsi6oDq7XAdggjOij5R1xGoQ1UXhKA,2512
3
3
  pre_commit_hooks/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pre_commit_hooks/run_bump2version/__init__.py,sha256=nhJ2kdUjSteGVjatTfMSeQb92zIlfiwyeHll_7_nzvM,1581
@@ -9,9 +9,9 @@ pre_commit_hooks/run_hatch_version/__init__.py,sha256=bADWwm3tTgUrDMynBag2Z_hVkn
9
9
  pre_commit_hooks/run_hatch_version/__main__.py,sha256=XeMLmgm1HMujkYhaF9LcMygBrwa2KqIGMzznY106gd8,154
10
10
  pre_commit_hooks/run_ruff_format/__init__.py,sha256=Lr_9M0WHhJl6WARAf8Lr830PG9bMbkDXvNSmEkrSxK8,1993
11
11
  pre_commit_hooks/run_ruff_format/__main__.py,sha256=faesqqpMaesg5r-LvkkQt1W9kahvNr-60K3SMYv1NgY,152
12
- pre_commit_hooks/run_uv_pip_compile/__init__.py,sha256=HJHsMgOuxAtWQKzK-J-MGRFtuvr9eHfopfgaW1I_uGo,2368
12
+ pre_commit_hooks/run_uv_pip_compile/__init__.py,sha256=bFzO49-Tw0rYJ1Eby25gX4-wChXOh2QbB5YiQUl5WNE,3629
13
13
  pre_commit_hooks/run_uv_pip_compile/__main__.py,sha256=LLlM3xVN7l5cxZ0yD_8He8n_GEmQqn_d-2wl6BQtqoA,155
14
- dycw_pre_commit_hooks-0.9.23.dist-info/METADATA,sha256=OGJKpQi8_UsKbCf3CZMaZkIPlzGHH-TIEMjUHSuGnfw,1135
15
- dycw_pre_commit_hooks-0.9.23.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
16
- dycw_pre_commit_hooks-0.9.23.dist-info/entry_points.txt,sha256=E5ZGYo3x6IF71IHDEhXJYfTHRRIrjzzuxsiYgVkCDQE,302
17
- dycw_pre_commit_hooks-0.9.23.dist-info/RECORD,,
14
+ dycw_pre_commit_hooks-0.9.26.dist-info/METADATA,sha256=qx4GePYf_QjIUgNzDJmMV6Wvs0m07yTWwyGf1p6xbmQ,1191
15
+ dycw_pre_commit_hooks-0.9.26.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ dycw_pre_commit_hooks-0.9.26.dist-info/entry_points.txt,sha256=E5ZGYo3x6IF71IHDEhXJYfTHRRIrjzzuxsiYgVkCDQE,302
17
+ dycw_pre_commit_hooks-0.9.26.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.9.23"
3
+ __version__ = "0.9.26"
@@ -4,29 +4,62 @@ from pathlib import Path
4
4
  from re import sub
5
5
  from subprocess import CalledProcessError, check_call
6
6
  from tempfile import TemporaryDirectory
7
+ from typing import TYPE_CHECKING, Literal
7
8
 
8
- from click import command, option
9
+ from click import Choice, command, option
9
10
  from loguru import logger
10
11
 
11
12
  from pre_commit_hooks.common import REQUIREMENTS_TXT
12
13
 
14
+ if TYPE_CHECKING:
15
+ from collections.abc import Iterable
16
+
13
17
 
14
18
  @command()
15
19
  @option(
16
- "--python-version",
17
- help="The minimum Python version that should be supported by the compiled requirements",
20
+ "--output-file",
21
+ default=REQUIREMENTS_TXT,
22
+ help="Write the compiled requirements to the given `requirements.txt` file",
23
+ )
24
+ @option("--extra", multiple=True, help="Optional dependencies")
25
+ @option(
26
+ "--python-platform",
27
+ type=Choice(["windows", "linux", "macos"], case_sensitive=False),
28
+ help="The platform for which requirements should be resolved",
18
29
  )
19
- def main(*, python_version: str | None) -> bool:
30
+ @option(
31
+ "--python-version", default=None, help="The Python version to use for resolution"
32
+ )
33
+ def main(
34
+ *,
35
+ output_file: Path | str = REQUIREMENTS_TXT,
36
+ extra: tuple[str, ...] = (),
37
+ python_platform: Literal["windows", "linux", "macos"] | None = None,
38
+ python_version: str | None = None,
39
+ ) -> bool:
20
40
  """CLI for the `run-uv-pip-compile` hook."""
21
- return _process(python_version=python_version)
22
-
23
-
24
- def _process(*, python_version: str | None) -> bool:
25
- curr = _read_requirements_txt(REQUIREMENTS_TXT)
26
- latest = _run_uv_pip_compile(python_version=python_version)
41
+ return _process(
42
+ output_file=Path(output_file),
43
+ extra=None if len(extra) == 0 else list(extra),
44
+ python_platform=python_platform,
45
+ python_version=python_version,
46
+ )
47
+
48
+
49
+ def _process(
50
+ *,
51
+ extra: Iterable[str] | None = None,
52
+ output_file: Path = REQUIREMENTS_TXT,
53
+ python_platform: Literal["windows", "linux", "macos"] | None = None,
54
+ python_version: str | None = None,
55
+ ) -> bool:
56
+ curr = _read_requirements_txt(output_file)
57
+ latest = _run_uv_pip_compile(
58
+ extra=extra, python_platform=python_platform, python_version=python_version
59
+ )
27
60
  if curr == latest:
28
61
  return True
29
- _write_requirements_txt(latest)
62
+ _write_requirements_txt(latest, path=output_file)
30
63
  return False
31
64
 
32
65
 
@@ -38,25 +71,33 @@ def _read_requirements_txt(path: Path, /) -> str | None:
38
71
  return None
39
72
 
40
73
 
41
- def _run_uv_pip_compile(*, python_version: str | None) -> str:
74
+ def _run_uv_pip_compile(
75
+ *,
76
+ extra: Iterable[str] | None = None,
77
+ python_platform: Literal["windows", "linux", "macos"] | None = None,
78
+ python_version: str | None = None,
79
+ ) -> str:
80
+ cmd: list[str] = [
81
+ "uv",
82
+ "pip",
83
+ "compile",
84
+ "--extra=dev",
85
+ "--prerelease=explicit",
86
+ "--quiet",
87
+ "--upgrade",
88
+ ]
89
+ if extra is not None:
90
+ cmd.extend(f"--extra={e}" for e in extra)
91
+ if python_platform is not None:
92
+ cmd.append(f"--python-platform={python_platform}")
93
+ if python_version is not None:
94
+ cmd.append(f"--python-version={python_version}")
42
95
  with TemporaryDirectory() as temp:
43
- temp_file = Path(temp, "requirements.txt")
44
- cmd = (
45
- [
46
- "uv",
47
- "pip",
48
- "compile",
49
- "--extra=dev",
50
- "--prerelease=explicit",
51
- "--quiet",
52
- f"--output-file={temp_file.as_posix()}",
53
- "--upgrade",
54
- ]
55
- + ([] if python_version is None else [f"--python-version={python_version}"])
56
- + [
57
- "pyproject.toml" # don't use absolute path
58
- ]
59
- )
96
+ temp_file = Path(temp, "temp.txt")
97
+ cmd.extend([
98
+ f"--output-file={temp_file.as_posix()}",
99
+ "pyproject.toml", # don't use absolute path
100
+ ])
60
101
  try:
61
102
  _ = check_call(cmd)
62
103
  except CalledProcessError:
@@ -75,6 +116,6 @@ def _fix_header_line(line: str, temp_file: Path, /) -> str:
75
116
  return sub(str(temp_file), temp_file.name, line)
76
117
 
77
118
 
78
- def _write_requirements_txt(contents: str, /) -> None:
79
- with REQUIREMENTS_TXT.open(mode="w") as fh:
119
+ def _write_requirements_txt(contents: str, /, *, path: Path = REQUIREMENTS_TXT) -> None:
120
+ with path.open(mode="w") as fh:
80
121
  _ = fh.write(contents)