dycw-pre-commit-hooks 0.9.24__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.
- {dycw_pre_commit_hooks-0.9.24.dist-info → dycw_pre_commit_hooks-0.9.26.dist-info}/METADATA +3 -3
- {dycw_pre_commit_hooks-0.9.24.dist-info → dycw_pre_commit_hooks-0.9.26.dist-info}/RECORD +6 -6
- pre_commit_hooks/__init__.py +1 -1
- pre_commit_hooks/run_uv_pip_compile/__init__.py +72 -31
- {dycw_pre_commit_hooks-0.9.24.dist-info → dycw_pre_commit_hooks-0.9.26.dist-info}/WHEEL +0 -0
- {dycw_pre_commit_hooks-0.9.24.dist-info → dycw_pre_commit_hooks-0.9.26.dist-info}/entry_points.txt +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dycw-pre-commit-hooks
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.26
|
|
4
4
|
Author-email: Derek Wan <d.wan@icloud.com>
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Requires-Dist: click<8.2,>=8.1.8
|
|
7
|
-
Requires-Dist: dycw-utilities<0.
|
|
7
|
+
Requires-Dist: dycw-utilities<0.95,>=0.94.13
|
|
8
8
|
Requires-Dist: loguru<0.8,>=0.7.3
|
|
9
9
|
Requires-Dist: semver<3.1,>=3.0.4
|
|
10
10
|
Requires-Dist: tomlkit<0.14,>=0.13.2
|
|
@@ -12,7 +12,7 @@ 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
14
|
Requires-Dist: hatch<1.15,>=1.14.0; extra == 'dev'
|
|
15
|
-
Requires-Dist: setuptools<75.9,>=75.8.
|
|
15
|
+
Requires-Dist: setuptools<75.9,>=75.8.1; extra == 'dev'
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
|
|
18
18
|
# pre-commit-hooks
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
pre_commit_hooks/__init__.py,sha256=
|
|
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=
|
|
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.
|
|
15
|
-
dycw_pre_commit_hooks-0.9.
|
|
16
|
-
dycw_pre_commit_hooks-0.9.
|
|
17
|
-
dycw_pre_commit_hooks-0.9.
|
|
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,,
|
pre_commit_hooks/__init__.py
CHANGED
|
@@ -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
|
-
"--
|
|
17
|
-
|
|
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
|
-
|
|
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(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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(
|
|
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, "
|
|
44
|
-
cmd
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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,
|
|
79
|
-
with
|
|
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)
|
|
File without changes
|
{dycw_pre_commit_hooks-0.9.24.dist-info → dycw_pre_commit_hooks-0.9.26.dist-info}/entry_points.txt
RENAMED
|
File without changes
|