dycw-pre-commit-hooks 0.10.18__tar.gz → 0.10.20__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.10.18 → dycw_pre_commit_hooks-0.10.20}/PKG-INFO +2 -7
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/README.md +1 -6
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/pre_commit_hooks/__init__.py +1 -1
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/pre_commit_hooks/common.py +0 -1
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/pyproject.toml +4 -7
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/uv.lock +3 -3
- dycw_pre_commit_hooks-0.10.18/pre_commit_hooks/run_dockfmt/__init__.py +0 -45
- dycw_pre_commit_hooks-0.10.18/pre_commit_hooks/run_dockfmt/__main__.py +0 -6
- dycw_pre_commit_hooks-0.10.18/pre_commit_hooks/run_hatch_version/__init__.py +0 -58
- dycw_pre_commit_hooks-0.10.18/pre_commit_hooks/run_hatch_version/__main__.py +0 -6
- dycw_pre_commit_hooks-0.10.18/pre_commit_hooks/run_uv_pip_compile/__init__.py +0 -121
- dycw_pre_commit_hooks-0.10.18/pre_commit_hooks/run_uv_pip_compile/__main__.py +0 -6
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/.envrc +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/.github/workflows/pull-request.yml +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/.github/workflows/push.yml +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/.gitignore +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/.pre-commit-config.yaml +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/.pre-commit-hooks.yaml +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/.python-version +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/pre_commit_hooks/py.typed +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/pre_commit_hooks/run_bump2version/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/pre_commit_hooks/run_bump2version/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/pre_commit_hooks/run_bump_my_version/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/pre_commit_hooks/run_bump_my_version/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/pre_commit_hooks/run_ruff_format/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/pre_commit_hooks/run_ruff_format/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/run-test-hook.sh +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/tests/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/tests/test_main.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dycw-pre-commit-hooks
|
|
3
|
-
Version: 0.10.
|
|
3
|
+
Version: 0.10.20
|
|
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
|
|
@@ -29,13 +29,8 @@ My [`pre-commit`](https://pre-commit.com/) hooks.
|
|
|
29
29
|
- repo: https://github.com/dycw/pre-commit-hooks
|
|
30
30
|
rev: master
|
|
31
31
|
hooks:
|
|
32
|
-
- id: run-
|
|
33
|
-
args: [--setup-cfg]
|
|
34
|
-
- id: run-dockfmt
|
|
35
|
-
- id: run-hatch-version
|
|
32
|
+
- id: run-bump-my-version
|
|
36
33
|
- id: run-ruff-format
|
|
37
|
-
- id: run-uv-pip-compile
|
|
38
|
-
args: [--python-version=3.9]
|
|
39
34
|
```
|
|
40
35
|
|
|
41
36
|
1. Update your `.pre-commit-config.yaml`:
|
|
@@ -15,13 +15,8 @@ My [`pre-commit`](https://pre-commit.com/) hooks.
|
|
|
15
15
|
- repo: https://github.com/dycw/pre-commit-hooks
|
|
16
16
|
rev: master
|
|
17
17
|
hooks:
|
|
18
|
-
- id: run-
|
|
19
|
-
args: [--setup-cfg]
|
|
20
|
-
- id: run-dockfmt
|
|
21
|
-
- id: run-hatch-version
|
|
18
|
+
- id: run-bump-my-version
|
|
22
19
|
- id: run-ruff-format
|
|
23
|
-
- id: run-uv-pip-compile
|
|
24
|
-
args: [--python-version=3.9]
|
|
25
20
|
```
|
|
26
21
|
|
|
27
22
|
1. Update your `.pre-commit-config.yaml`:
|
|
@@ -8,8 +8,8 @@ requires = ["hatchling"]
|
|
|
8
8
|
# dependency groups
|
|
9
9
|
[dependency-groups]
|
|
10
10
|
dev = [
|
|
11
|
-
"dycw-utilities[test]
|
|
12
|
-
"setuptools
|
|
11
|
+
"dycw-utilities[test]",
|
|
12
|
+
"setuptools", # https://github.com/theY4Kman/pytest-only/issues/14
|
|
13
13
|
]
|
|
14
14
|
|
|
15
15
|
# project
|
|
@@ -27,20 +27,17 @@ dependencies = [
|
|
|
27
27
|
name = "dycw-pre-commit-hooks"
|
|
28
28
|
readme = "README.md"
|
|
29
29
|
requires-python = ">= 3.11"
|
|
30
|
-
version = "0.10.
|
|
30
|
+
version = "0.10.20"
|
|
31
31
|
|
|
32
32
|
[project.scripts]
|
|
33
33
|
run-bump-my-version = "pre_commit_hooks.run_bump_my_version:main"
|
|
34
34
|
run-bump2version = "pre_commit_hooks.run_bump2version:main"
|
|
35
|
-
run-dockfmt = "pre_commit_hooks.run_dockfmt:main"
|
|
36
|
-
run-hatch-version = "pre_commit_hooks.run_hatch_version:main"
|
|
37
35
|
run-ruff-format = "pre_commit_hooks.run_ruff_format:main"
|
|
38
|
-
run-uv-pip-compile = "pre_commit_hooks.run_uv_pip_compile:main"
|
|
39
36
|
|
|
40
37
|
# bump-my-version
|
|
41
38
|
[tool.bumpversion]
|
|
42
39
|
allow_dirty = true
|
|
43
|
-
current_version = "0.10.
|
|
40
|
+
current_version = "0.10.20"
|
|
44
41
|
|
|
45
42
|
[[tool.bumpversion.files]]
|
|
46
43
|
filename = "src/pre_commit_hooks/__init__.py"
|
|
@@ -380,7 +380,7 @@ wheels = [
|
|
|
380
380
|
|
|
381
381
|
[[package]]
|
|
382
382
|
name = "dycw-pre-commit-hooks"
|
|
383
|
-
version = "0.10.
|
|
383
|
+
version = "0.10.20"
|
|
384
384
|
source = { editable = "." }
|
|
385
385
|
dependencies = [
|
|
386
386
|
{ name = "click" },
|
|
@@ -411,8 +411,8 @@ requires-dist = [
|
|
|
411
411
|
|
|
412
412
|
[package.metadata.requires-dev]
|
|
413
413
|
dev = [
|
|
414
|
-
{ name = "dycw-utilities", extras = ["test"]
|
|
415
|
-
{ name = "setuptools"
|
|
414
|
+
{ name = "dycw-utilities", extras = ["test"] },
|
|
415
|
+
{ name = "setuptools" },
|
|
416
416
|
]
|
|
417
417
|
|
|
418
418
|
[[package]]
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from subprocess import check_output
|
|
5
|
-
from typing import TYPE_CHECKING
|
|
6
|
-
|
|
7
|
-
import click
|
|
8
|
-
from click import argument, command
|
|
9
|
-
|
|
10
|
-
if TYPE_CHECKING:
|
|
11
|
-
from collections.abc import Iterator
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@command()
|
|
15
|
-
@argument(
|
|
16
|
-
"paths",
|
|
17
|
-
nargs=-1,
|
|
18
|
-
type=click.Path(
|
|
19
|
-
exists=True, file_okay=True, dir_okay=False, readable=True, path_type=Path
|
|
20
|
-
),
|
|
21
|
-
)
|
|
22
|
-
def main(paths: tuple[Path, ...], /) -> bool:
|
|
23
|
-
"""CLI for the `run-dockfmt` hook."""
|
|
24
|
-
results = list(_yield_outcomes(*paths)) # run all
|
|
25
|
-
return all(results)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def _yield_outcomes(*paths: Path) -> Iterator[bool]:
|
|
29
|
-
for path in paths:
|
|
30
|
-
if path.name == "Dockerfile":
|
|
31
|
-
yield _process(path)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def _process(path: Path, /) -> bool:
|
|
35
|
-
with path.open() as fh:
|
|
36
|
-
current = fh.read()
|
|
37
|
-
strip = "\t\n"
|
|
38
|
-
proposed = check_output(["dockfmt", "fmt", path.as_posix()], text=True).lstrip(
|
|
39
|
-
strip
|
|
40
|
-
)
|
|
41
|
-
if current == proposed:
|
|
42
|
-
return True
|
|
43
|
-
with path.open(mode="w") as fh:
|
|
44
|
-
_ = fh.write(proposed)
|
|
45
|
-
return False
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from subprocess import PIPE, STDOUT, CalledProcessError, check_call
|
|
5
|
-
from typing import Any, cast
|
|
6
|
-
|
|
7
|
-
from click import command
|
|
8
|
-
from loguru import logger
|
|
9
|
-
from tomlkit.container import Container
|
|
10
|
-
|
|
11
|
-
from pre_commit_hooks.common import check_versions, read_pyproject
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@command()
|
|
15
|
-
def main() -> bool:
|
|
16
|
-
"""CLI for the `run-hatch-version` hook."""
|
|
17
|
-
return _process()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def _process() -> bool:
|
|
21
|
-
path = _get_path_version_file()
|
|
22
|
-
pattern = r'^__version__ = "(\d+\.\d+\.\d+)"$'
|
|
23
|
-
version = check_versions(path, pattern, "run-hatch-version")
|
|
24
|
-
if version is None:
|
|
25
|
-
return True
|
|
26
|
-
cmd = ["hatch", "version", str(version)]
|
|
27
|
-
try:
|
|
28
|
-
_ = check_call(cmd, stdout=PIPE, stderr=STDOUT)
|
|
29
|
-
except CalledProcessError as error:
|
|
30
|
-
if error.returncode != 1:
|
|
31
|
-
logger.exception("Failed to run {cmd!r}", cmd=" ".join(cmd))
|
|
32
|
-
except FileNotFoundError:
|
|
33
|
-
logger.exception(
|
|
34
|
-
"Failed to run {cmd!r}. Is `hatch` installed?", cmd=" ".join(cmd)
|
|
35
|
-
)
|
|
36
|
-
else:
|
|
37
|
-
return True
|
|
38
|
-
return False
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def _get_path_version_file() -> Path:
|
|
42
|
-
pyproject = read_pyproject()
|
|
43
|
-
try:
|
|
44
|
-
tool = cast(Container, pyproject.doc["tool"])
|
|
45
|
-
except KeyError:
|
|
46
|
-
logger.exception('pyproject.toml has no "tool" section')
|
|
47
|
-
raise
|
|
48
|
-
try:
|
|
49
|
-
hatch = cast(Container, tool["hatch"])
|
|
50
|
-
except KeyError:
|
|
51
|
-
logger.exception('pyproject.toml has no "tool.hatch" section')
|
|
52
|
-
raise
|
|
53
|
-
try:
|
|
54
|
-
version = cast(Container, hatch["version"])
|
|
55
|
-
except KeyError:
|
|
56
|
-
logger.exception('pyproject.toml has no "tool.hatch.version" section')
|
|
57
|
-
raise
|
|
58
|
-
return Path(cast(Any, version["path"]))
|
|
@@ -1,121 +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
|
-
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)
|
|
File without changes
|
{dycw_pre_commit_hooks-0.10.18 → dycw_pre_commit_hooks-0.10.20}/.github/workflows/pull-request.yml
RENAMED
|
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
|
|
File without changes
|