dycw-pre-commit-hooks 0.9.23__tar.gz → 0.9.26__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.
Potentially problematic release.
This version of dycw-pre-commit-hooks might be problematic. Click here for more details.
- dycw_pre_commit_hooks-0.9.26/.envrc +2 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/.github/workflows/push.yml +4 -4
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/.pre-commit-config.yaml +3 -3
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/.pre-commit-hooks.yaml +16 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/PKG-INFO +9 -8
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/__init__.py +1 -1
- dycw_pre_commit_hooks-0.9.26/pre_commit_hooks/run_uv_pip_compile/__init__.py +121 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pyproject.toml +8 -8
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/requirements.txt +68 -32
- dycw_pre_commit_hooks-0.9.26/run-test-hook.sh +28 -0
- dycw_pre_commit_hooks-0.9.23/.envrc +0 -1
- dycw_pre_commit_hooks-0.9.23/pre_commit_hooks/run_uv_pip_compile/__init__.py +0 -80
- dycw_pre_commit_hooks-0.9.23/try-repo/run-bump2version.sh +0 -9
- dycw_pre_commit_hooks-0.9.23/try-repo/run-dockfmt.sh +0 -9
- dycw_pre_commit_hooks-0.9.23/try-repo/run-hatch-version.sh +0 -9
- dycw_pre_commit_hooks-0.9.23/try-repo/run-ruff-format.sh +0 -9
- dycw_pre_commit_hooks-0.9.23/try-repo/run-uv-pip-compile.sh +0 -9
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/.gitignore +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/README.md +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/common.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/py.typed +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/run_bump2version/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/run_bump2version/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/run_dockfmt/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/run_dockfmt/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/run_hatch_version/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/run_hatch_version/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/run_ruff_format/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/run_ruff_format/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/pre_commit_hooks/run_uv_pip_compile/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/tests/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.9.23 → dycw_pre_commit_hooks-0.9.26}/tests/test_main.py +0 -0
|
@@ -9,7 +9,7 @@ jobs:
|
|
|
9
9
|
tag:
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
steps:
|
|
12
|
-
- uses: actions/checkout@
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
13
|
- uses: butlerlogic/action-autotag@1.1.2 # https://github.com/ButlerLogic/action-autotag/issues/45#issuecomment-1825726927
|
|
14
14
|
env:
|
|
15
15
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
@@ -22,13 +22,13 @@ jobs:
|
|
|
22
22
|
runs-on: ubuntu-latest
|
|
23
23
|
needs: tag
|
|
24
24
|
steps:
|
|
25
|
-
- uses: actions/checkout@
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
26
|
- run: |
|
|
27
27
|
python -m venv venv
|
|
28
28
|
source venv/bin/activate
|
|
29
29
|
python -m pip install --upgrade pip hatch
|
|
30
30
|
hatch build
|
|
31
|
-
- uses: actions/upload-artifact@
|
|
31
|
+
- uses: actions/upload-artifact@v4
|
|
32
32
|
with:
|
|
33
33
|
name: artifacts
|
|
34
34
|
path: dist/*
|
|
@@ -39,7 +39,7 @@ jobs:
|
|
|
39
39
|
needs:
|
|
40
40
|
- build
|
|
41
41
|
steps:
|
|
42
|
-
- uses: actions/download-artifact@
|
|
42
|
+
- uses: actions/download-artifact@v4
|
|
43
43
|
with:
|
|
44
44
|
name: artifacts
|
|
45
45
|
path: dist
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
repos:
|
|
2
2
|
# fixers
|
|
3
3
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
4
|
-
rev: v0.
|
|
4
|
+
rev: v0.9.3
|
|
5
5
|
hooks:
|
|
6
6
|
- id: ruff
|
|
7
7
|
args: [--fix]
|
|
8
8
|
- id: ruff-format
|
|
9
9
|
- repo: https://github.com/dycw/pre-commit-hooks
|
|
10
|
-
rev: 0.9.
|
|
10
|
+
rev: 0.9.23
|
|
11
11
|
hooks:
|
|
12
12
|
- id: run-hatch-version
|
|
13
13
|
- id: run-ruff-format
|
|
@@ -19,7 +19,7 @@ repos:
|
|
|
19
19
|
- id: pretty-format-toml
|
|
20
20
|
args: [--autofix, --trailing-commas]
|
|
21
21
|
- repo: https://github.com/pamoller/xmlformatter
|
|
22
|
-
rev: v0.2.
|
|
22
|
+
rev: v0.2.8
|
|
23
23
|
hooks:
|
|
24
24
|
- id: xml-formatter
|
|
25
25
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
@@ -32,3 +32,19 @@
|
|
|
32
32
|
files: ^pyproject\.toml$
|
|
33
33
|
pass_filenames: false
|
|
34
34
|
description: Run `uv pip compile`
|
|
35
|
+
- id: test-hook
|
|
36
|
+
name: test-hook
|
|
37
|
+
entry: run-uv-pip-compile
|
|
38
|
+
language: python
|
|
39
|
+
files: ^pyproject\.toml$
|
|
40
|
+
pass_filenames: false
|
|
41
|
+
description: Run `uv pip compile`
|
|
42
|
+
args: [
|
|
43
|
+
# --output-file=requirements-macos.txt,
|
|
44
|
+
# --extra=interactive,
|
|
45
|
+
# --python-platform=macos,
|
|
46
|
+
# --python-version=3.12,
|
|
47
|
+
--output-file=requirements-linux.txt,
|
|
48
|
+
--python-platform=linux,
|
|
49
|
+
--python-version=3.12,
|
|
50
|
+
]
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
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
|
-
Requires-Dist: click<8.2,>=8.1.
|
|
7
|
-
Requires-Dist: dycw-utilities<0.
|
|
8
|
-
Requires-Dist: loguru<0.8,>=0.7.
|
|
9
|
-
Requires-Dist: semver<3.1,>=3.0.
|
|
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.
|
|
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.
|
|
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
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from re import sub
|
|
5
|
+
from subprocess import CalledProcessError, check_call
|
|
6
|
+
from tempfile import TemporaryDirectory
|
|
7
|
+
from typing import TYPE_CHECKING, Literal
|
|
8
|
+
|
|
9
|
+
from click import Choice, command, option
|
|
10
|
+
from loguru import logger
|
|
11
|
+
|
|
12
|
+
from pre_commit_hooks.common import REQUIREMENTS_TXT
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from collections.abc import Iterable
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@command()
|
|
19
|
+
@option(
|
|
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",
|
|
29
|
+
)
|
|
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:
|
|
40
|
+
"""CLI for the `run-uv-pip-compile` hook."""
|
|
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
|
+
)
|
|
60
|
+
if curr == latest:
|
|
61
|
+
return True
|
|
62
|
+
_write_requirements_txt(latest, path=output_file)
|
|
63
|
+
return False
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _read_requirements_txt(path: Path, /) -> str | None:
|
|
67
|
+
try:
|
|
68
|
+
with path.open() as fh:
|
|
69
|
+
return fh.read()
|
|
70
|
+
except FileNotFoundError:
|
|
71
|
+
return None
|
|
72
|
+
|
|
73
|
+
|
|
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}")
|
|
95
|
+
with TemporaryDirectory() as temp:
|
|
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
|
+
])
|
|
101
|
+
try:
|
|
102
|
+
_ = check_call(cmd)
|
|
103
|
+
except CalledProcessError:
|
|
104
|
+
logger.exception("Failed to run {cmd!r}", cmd=" ".join(cmd))
|
|
105
|
+
raise
|
|
106
|
+
with temp_file.open(mode="r") as fh:
|
|
107
|
+
contents = fh.read()
|
|
108
|
+
return _fix_header(contents, temp_file) + "\n"
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _fix_header(text: str, temp_file: Path, /) -> str:
|
|
112
|
+
return "\n".join(_fix_header_line(line, temp_file) for line in text.splitlines())
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _fix_header_line(line: str, temp_file: Path, /) -> str:
|
|
116
|
+
return sub(str(temp_file), temp_file.name, line)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _write_requirements_txt(contents: str, /, *, path: Path = REQUIREMENTS_TXT) -> None:
|
|
120
|
+
with path.open(mode="w") as fh:
|
|
121
|
+
_ = fh.write(contents)
|
|
@@ -8,12 +8,12 @@ requires = ["hatchling"]
|
|
|
8
8
|
[project]
|
|
9
9
|
authors = [{name = "Derek Wan", email = "d.wan@icloud.com"}]
|
|
10
10
|
dependencies = [
|
|
11
|
-
"click >= 8.1.
|
|
12
|
-
"dycw-utilities >= 0.
|
|
13
|
-
"loguru >= 0.7.
|
|
14
|
-
"semver >= 3.0.
|
|
11
|
+
"click >= 8.1.8, < 8.2",
|
|
12
|
+
"dycw-utilities >= 0.94.13, < 0.95",
|
|
13
|
+
"loguru >= 0.7.3, < 0.8",
|
|
14
|
+
"semver >= 3.0.4, < 3.1",
|
|
15
15
|
"tomlkit >= 0.13.2, < 0.14",
|
|
16
|
-
"xdg-base-dirs >= 6.0.
|
|
16
|
+
"xdg-base-dirs >= 6.0.2, < 6.1",
|
|
17
17
|
]
|
|
18
18
|
dynamic = ["version"]
|
|
19
19
|
name = "dycw-pre-commit-hooks"
|
|
@@ -23,7 +23,8 @@ requires-python = ">= 3.11"
|
|
|
23
23
|
[project.optional-dependencies]
|
|
24
24
|
dev = [
|
|
25
25
|
"dycw-utilities[test]",
|
|
26
|
-
"hatch >= 1.
|
|
26
|
+
"hatch >= 1.14.0, < 1.15",
|
|
27
|
+
"setuptools >= 75.8.1, < 75.9", # https://github.com/theY4Kman/pytest-only/issues/14
|
|
27
28
|
]
|
|
28
29
|
|
|
29
30
|
[project.scripts]
|
|
@@ -118,9 +119,8 @@ preview = true
|
|
|
118
119
|
[tool.ruff.lint]
|
|
119
120
|
fixable = ["ALL"]
|
|
120
121
|
ignore = [
|
|
121
|
-
"ANN101", # missing-type-self
|
|
122
|
-
"ANN102", # missing-type-cls
|
|
123
122
|
"ANN401", # any-type
|
|
123
|
+
"ASYNC109", # async-function-with-timeout
|
|
124
124
|
"C901", # complex-structure
|
|
125
125
|
"D100", # undocumented-public-module
|
|
126
126
|
"D101", # undocumented-public-class
|
|
@@ -1,48 +1,54 @@
|
|
|
1
1
|
# This file was autogenerated by uv via the following command:
|
|
2
2
|
# uv pip compile --extra=dev --prerelease=explicit --output-file=requirements.txt --python-version=3.11 pyproject.toml
|
|
3
|
-
anyio==4.
|
|
3
|
+
anyio==4.8.0
|
|
4
4
|
# via httpx
|
|
5
|
-
attrs==
|
|
5
|
+
attrs==25.1.0
|
|
6
6
|
# via hypothesis
|
|
7
7
|
backports-tarfile==1.2.0
|
|
8
8
|
# via jaraco-context
|
|
9
|
-
certifi==
|
|
9
|
+
certifi==2025.1.31
|
|
10
10
|
# via
|
|
11
11
|
# httpcore
|
|
12
12
|
# httpx
|
|
13
|
-
click==8.1.
|
|
13
|
+
click==8.1.8
|
|
14
14
|
# via
|
|
15
15
|
# dycw-pre-commit-hooks (pyproject.toml)
|
|
16
16
|
# hatch
|
|
17
17
|
# userpath
|
|
18
|
+
coverage==7.6.12
|
|
19
|
+
# via
|
|
20
|
+
# coverage-conditional-plugin
|
|
21
|
+
# pytest-cov
|
|
22
|
+
coverage-conditional-plugin==0.9.0
|
|
23
|
+
# via dycw-utilities
|
|
18
24
|
distlib==0.3.9
|
|
19
25
|
# via virtualenv
|
|
20
|
-
dycw-utilities==0.
|
|
26
|
+
dycw-utilities==0.94.13
|
|
21
27
|
# via dycw-pre-commit-hooks (pyproject.toml)
|
|
22
28
|
execnet==2.1.1
|
|
23
29
|
# via pytest-xdist
|
|
24
|
-
filelock==3.
|
|
30
|
+
filelock==3.17.0
|
|
25
31
|
# via virtualenv
|
|
26
32
|
h11==0.14.0
|
|
27
33
|
# via httpcore
|
|
28
|
-
hatch==1.
|
|
34
|
+
hatch==1.14.0
|
|
29
35
|
# via dycw-pre-commit-hooks (pyproject.toml)
|
|
30
|
-
hatchling==1.
|
|
36
|
+
hatchling==1.27.0
|
|
31
37
|
# via hatch
|
|
32
|
-
httpcore==1.0.
|
|
38
|
+
httpcore==1.0.7
|
|
33
39
|
# via httpx
|
|
34
|
-
httpx==0.
|
|
40
|
+
httpx==0.28.1
|
|
35
41
|
# via hatch
|
|
36
42
|
hyperlink==21.0.0
|
|
37
43
|
# via hatch
|
|
38
|
-
hypothesis==6.
|
|
44
|
+
hypothesis==6.127.2
|
|
39
45
|
# via dycw-utilities
|
|
40
46
|
idna==3.10
|
|
41
47
|
# via
|
|
42
48
|
# anyio
|
|
43
49
|
# httpx
|
|
44
50
|
# hyperlink
|
|
45
|
-
importlib-metadata==8.
|
|
51
|
+
importlib-metadata==8.6.1
|
|
46
52
|
# via keyring
|
|
47
53
|
iniconfig==2.0.0
|
|
48
54
|
# via pytest
|
|
@@ -52,20 +58,23 @@ jaraco-context==6.0.1
|
|
|
52
58
|
# via keyring
|
|
53
59
|
jaraco-functools==4.1.0
|
|
54
60
|
# via keyring
|
|
55
|
-
keyring==25.
|
|
61
|
+
keyring==25.6.0
|
|
56
62
|
# via hatch
|
|
57
|
-
loguru==0.7.
|
|
63
|
+
loguru==0.7.3
|
|
58
64
|
# via dycw-pre-commit-hooks (pyproject.toml)
|
|
59
65
|
markdown-it-py==3.0.0
|
|
60
66
|
# via rich
|
|
61
67
|
mdurl==0.1.2
|
|
62
68
|
# via markdown-it-py
|
|
63
|
-
more-itertools==10.
|
|
69
|
+
more-itertools==10.6.0
|
|
64
70
|
# via
|
|
65
71
|
# jaraco-classes
|
|
66
72
|
# jaraco-functools
|
|
67
|
-
|
|
73
|
+
numpy==2.2.3
|
|
74
|
+
# via pytest-rng
|
|
75
|
+
packaging==24.2
|
|
68
76
|
# via
|
|
77
|
+
# coverage-conditional-plugin
|
|
69
78
|
# hatch
|
|
70
79
|
# hatchling
|
|
71
80
|
# pytest
|
|
@@ -84,51 +93,78 @@ pluggy==1.5.0
|
|
|
84
93
|
# pytest
|
|
85
94
|
ptyprocess==0.7.0
|
|
86
95
|
# via pexpect
|
|
87
|
-
pygments==2.
|
|
96
|
+
pygments==2.19.1
|
|
88
97
|
# via rich
|
|
89
|
-
pytest==8.3.
|
|
98
|
+
pytest==8.3.4
|
|
90
99
|
# via
|
|
91
100
|
# dycw-utilities
|
|
101
|
+
# pytest-asyncio
|
|
102
|
+
# pytest-cov
|
|
103
|
+
# pytest-datadir
|
|
104
|
+
# pytest-instafail
|
|
105
|
+
# pytest-only
|
|
92
106
|
# pytest-randomly
|
|
107
|
+
# pytest-regressions
|
|
93
108
|
# pytest-rerunfailures
|
|
109
|
+
# pytest-rng
|
|
94
110
|
# pytest-xdist
|
|
95
|
-
pytest-
|
|
111
|
+
pytest-asyncio==0.25.3
|
|
112
|
+
# via dycw-utilities
|
|
113
|
+
pytest-cov==6.0.0
|
|
114
|
+
# via dycw-utilities
|
|
115
|
+
pytest-datadir==1.6.1
|
|
116
|
+
# via pytest-regressions
|
|
117
|
+
pytest-instafail==0.5.0
|
|
118
|
+
# via dycw-utilities
|
|
119
|
+
pytest-only==2.1.2
|
|
120
|
+
# via dycw-utilities
|
|
121
|
+
pytest-randomly==3.16.0
|
|
122
|
+
# via dycw-utilities
|
|
123
|
+
pytest-regressions==2.7.0
|
|
124
|
+
# via dycw-utilities
|
|
125
|
+
pytest-rerunfailures==15.0
|
|
96
126
|
# via dycw-utilities
|
|
97
|
-
pytest-
|
|
127
|
+
pytest-rng==1.0.0
|
|
98
128
|
# via dycw-utilities
|
|
99
129
|
pytest-xdist==3.6.1
|
|
100
130
|
# via dycw-utilities
|
|
101
|
-
|
|
131
|
+
pyyaml==6.0.2
|
|
132
|
+
# via pytest-regressions
|
|
133
|
+
rich==13.9.4
|
|
102
134
|
# via hatch
|
|
103
|
-
semver==3.0.
|
|
135
|
+
semver==3.0.4
|
|
136
|
+
# via dycw-pre-commit-hooks (pyproject.toml)
|
|
137
|
+
setuptools==75.8.1
|
|
104
138
|
# via dycw-pre-commit-hooks (pyproject.toml)
|
|
105
139
|
shellingham==1.5.4
|
|
106
140
|
# via hatch
|
|
107
141
|
sniffio==1.3.1
|
|
108
|
-
# via
|
|
109
|
-
# anyio
|
|
110
|
-
# httpx
|
|
142
|
+
# via anyio
|
|
111
143
|
sortedcontainers==2.4.0
|
|
112
144
|
# via hypothesis
|
|
113
|
-
tomli
|
|
145
|
+
tomli==2.2.1
|
|
146
|
+
# via coverage
|
|
147
|
+
tomli-w==1.2.0
|
|
114
148
|
# via hatch
|
|
115
149
|
tomlkit==0.13.2
|
|
116
150
|
# via
|
|
117
151
|
# dycw-pre-commit-hooks (pyproject.toml)
|
|
118
152
|
# hatch
|
|
119
|
-
trove-classifiers==
|
|
153
|
+
trove-classifiers==2025.2.18.16
|
|
120
154
|
# via hatchling
|
|
121
155
|
typing-extensions==4.12.2
|
|
122
|
-
# via
|
|
156
|
+
# via
|
|
157
|
+
# anyio
|
|
158
|
+
# dycw-utilities
|
|
123
159
|
userpath==1.9.2
|
|
124
160
|
# via hatch
|
|
125
|
-
uv==0.
|
|
161
|
+
uv==0.6.3
|
|
126
162
|
# via hatch
|
|
127
|
-
virtualenv==20.
|
|
163
|
+
virtualenv==20.29.2
|
|
128
164
|
# via hatch
|
|
129
|
-
xdg-base-dirs==6.0.
|
|
165
|
+
xdg-base-dirs==6.0.2
|
|
130
166
|
# via dycw-pre-commit-hooks (pyproject.toml)
|
|
131
|
-
zipp==3.
|
|
167
|
+
zipp==3.21.0
|
|
132
168
|
# via importlib-metadata
|
|
133
169
|
zstandard==0.23.0
|
|
134
170
|
# via hatch
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# usage: edit the following in `.pre-commit-hooks.yaml`
|
|
4
|
+
#
|
|
5
|
+
# - id: test-hook
|
|
6
|
+
# name: test-hook
|
|
7
|
+
# entry: run-uv-pip-compile
|
|
8
|
+
# language: python
|
|
9
|
+
# files: ^pyproject\.toml$
|
|
10
|
+
# pass_filenames: false
|
|
11
|
+
# description: Run `uv pip compile`
|
|
12
|
+
# args: [
|
|
13
|
+
# --output-file=requirements-macos.txt
|
|
14
|
+
# --extra=interactive
|
|
15
|
+
# --python-platform=macos
|
|
16
|
+
# --python-version=3.12,
|
|
17
|
+
# ]
|
|
18
|
+
#
|
|
19
|
+
# then, in your project, run:
|
|
20
|
+
#
|
|
21
|
+
# ❯ ../pre-commit-hooks/run-test-hook.sh
|
|
22
|
+
|
|
23
|
+
PATH_DIR="$(
|
|
24
|
+
cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit
|
|
25
|
+
pwd -P
|
|
26
|
+
)"
|
|
27
|
+
|
|
28
|
+
pre-commit try-repo --verbose --all-files "$PATH_DIR" test-hook
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
layout pyenv 3.11.9
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from re import sub
|
|
5
|
-
from subprocess import CalledProcessError, check_call
|
|
6
|
-
from tempfile import TemporaryDirectory
|
|
7
|
-
|
|
8
|
-
from click import command, option
|
|
9
|
-
from loguru import logger
|
|
10
|
-
|
|
11
|
-
from pre_commit_hooks.common import REQUIREMENTS_TXT
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@command()
|
|
15
|
-
@option(
|
|
16
|
-
"--python-version",
|
|
17
|
-
help="The minimum Python version that should be supported by the compiled requirements",
|
|
18
|
-
)
|
|
19
|
-
def main(*, python_version: str | None) -> bool:
|
|
20
|
-
"""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)
|
|
27
|
-
if curr == latest:
|
|
28
|
-
return True
|
|
29
|
-
_write_requirements_txt(latest)
|
|
30
|
-
return False
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def _read_requirements_txt(path: Path, /) -> str | None:
|
|
34
|
-
try:
|
|
35
|
-
with path.open() as fh:
|
|
36
|
-
return fh.read()
|
|
37
|
-
except FileNotFoundError:
|
|
38
|
-
return None
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def _run_uv_pip_compile(*, python_version: str | None) -> str:
|
|
42
|
-
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
|
-
)
|
|
60
|
-
try:
|
|
61
|
-
_ = check_call(cmd)
|
|
62
|
-
except CalledProcessError:
|
|
63
|
-
logger.exception("Failed to run {cmd!r}", cmd=" ".join(cmd))
|
|
64
|
-
raise
|
|
65
|
-
with temp_file.open(mode="r") as fh:
|
|
66
|
-
contents = fh.read()
|
|
67
|
-
return _fix_header(contents, temp_file) + "\n"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def _fix_header(text: str, temp_file: Path, /) -> str:
|
|
71
|
-
return "\n".join(_fix_header_line(line, temp_file) for line in text.splitlines())
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def _fix_header_line(line: str, temp_file: Path, /) -> str:
|
|
75
|
-
return sub(str(temp_file), temp_file.name, line)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def _write_requirements_txt(contents: str, /) -> None:
|
|
79
|
-
with REQUIREMENTS_TXT.open(mode="w") as fh:
|
|
80
|
-
_ = fh.write(contents)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|