dycw-pre-commit-hooks 0.12.6__tar.gz → 0.12.8__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.
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/PKG-INFO +1 -1
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/pyproject.toml +2 -2
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/__init__.py +1 -1
- dycw_pre_commit_hooks-0.12.8/src/pre_commit_hooks/mirror_files/__init__.py +57 -0
- dycw_pre_commit_hooks-0.12.6/src/pre_commit_hooks/mirror_files/__init__.py +0 -36
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/.gitignore +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/README.md +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/check_submodules/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/check_submodules/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/common.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/format_requirements/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/format_requirements/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/mirror_files/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/py.typed +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/replace_sequence_str/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/replace_sequence_str/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/run_bump_my_version/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/run_bump_my_version/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/tag_commits/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/tag_commits/__main__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/tests/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/tests/format_requirements/__init__.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/tests/format_requirements/in.toml +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/tests/format_requirements/out.toml +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/tests/format_requirements/test_format_requirements.py +0 -0
- {dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/tests/test_main.py +0 -0
|
@@ -31,7 +31,7 @@ dependencies = [
|
|
|
31
31
|
name = "dycw-pre-commit-hooks"
|
|
32
32
|
readme = "README.md"
|
|
33
33
|
requires-python = ">= 3.12"
|
|
34
|
-
version = "0.12.
|
|
34
|
+
version = "0.12.8"
|
|
35
35
|
|
|
36
36
|
[project.scripts]
|
|
37
37
|
check-submodules = "pre_commit_hooks.check_submodules:main"
|
|
@@ -44,7 +44,7 @@ tag-commits = "pre_commit_hooks.tag_commits:main"
|
|
|
44
44
|
# bump-my-version
|
|
45
45
|
[tool.bumpversion]
|
|
46
46
|
allow_dirty = true
|
|
47
|
-
current_version = "0.12.
|
|
47
|
+
current_version = "0.12.8"
|
|
48
48
|
|
|
49
49
|
[[tool.bumpversion.files]]
|
|
50
50
|
filename = "src/pre_commit_hooks/__init__.py"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Literal
|
|
4
|
+
|
|
5
|
+
import utilities.click
|
|
6
|
+
from click import argument, command
|
|
7
|
+
from loguru import logger
|
|
8
|
+
from more_itertools import chunked
|
|
9
|
+
from utilities.atomicwrites import writer
|
|
10
|
+
|
|
11
|
+
from pre_commit_hooks.common import run_every_option, throttled_run
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from collections.abc import Iterable
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
from whenever import DateTimeDelta
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@command()
|
|
21
|
+
@argument("paths", nargs=-1, type=utilities.click.Path())
|
|
22
|
+
@run_every_option
|
|
23
|
+
def main(*, paths: tuple[Path, ...], run_every: DateTimeDelta | None = None) -> bool:
|
|
24
|
+
"""CLI for the `format-requirements` hook."""
|
|
25
|
+
return throttled_run("mirror-files", run_every, _process, paths)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _process(paths: Iterable[Path], /) -> bool:
|
|
29
|
+
paths = list(paths)
|
|
30
|
+
if len(paths) % 2 == 1:
|
|
31
|
+
logger.exception(f"Expected an even number of paths; got {len(paths)}")
|
|
32
|
+
raise RuntimeError
|
|
33
|
+
results = list(map(_process_pair, chunked(paths, 2, strict=True))) # run all
|
|
34
|
+
return all(results)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _process_pair(paths: Iterable[Path], /) -> bool:
|
|
38
|
+
path_from, path_to = paths
|
|
39
|
+
try:
|
|
40
|
+
text_from = path_from.read_text()
|
|
41
|
+
except FileNotFoundError:
|
|
42
|
+
logger.exception(f"Source file {str(path_from)!r} not found")
|
|
43
|
+
raise
|
|
44
|
+
try:
|
|
45
|
+
text_to = path_to.read_text()
|
|
46
|
+
except FileNotFoundError:
|
|
47
|
+
return _write_text(text_from, path_to)
|
|
48
|
+
return True if text_from == text_to else _write_text(text_from, path_to)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _write_text(text: str, path: Path, /) -> Literal[False]:
|
|
52
|
+
with writer(path, overwrite=True) as temp:
|
|
53
|
+
_ = temp.write_text(text)
|
|
54
|
+
return False
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
__all__ = ["main"]
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
|
-
|
|
5
|
-
import utilities.click
|
|
6
|
-
from click import argument, command
|
|
7
|
-
from loguru import logger
|
|
8
|
-
from more_itertools import chunked
|
|
9
|
-
from utilities.atomicwrites import writer
|
|
10
|
-
|
|
11
|
-
if TYPE_CHECKING:
|
|
12
|
-
from pathlib import Path
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@command()
|
|
16
|
-
@argument("paths", nargs=-1, type=utilities.click.Path())
|
|
17
|
-
def main(*, paths: tuple[Path, ...]) -> bool:
|
|
18
|
-
"""CLI for the `format-requirements` hook."""
|
|
19
|
-
if len(paths) % 2 == 1:
|
|
20
|
-
logger.exception(f"Expected an even number of paths; got {len(paths)}")
|
|
21
|
-
raise RuntimeError
|
|
22
|
-
results = list(map(_process, chunked(paths, 2, strict=True))) # run all
|
|
23
|
-
return all(results)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def _process(paths: list[Path], /) -> bool:
|
|
27
|
-
text_from, text_to = [p.read_text() for p in paths]
|
|
28
|
-
if text_from == text_to:
|
|
29
|
-
return True
|
|
30
|
-
_, path_to = paths
|
|
31
|
-
with writer(path_to, overwrite=True) as temp:
|
|
32
|
-
_ = temp.write_text(text_from)
|
|
33
|
-
return False
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
__all__ = ["main"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/pre_commit_hooks/common.py
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
|
{dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/tests/format_requirements/in.toml
RENAMED
|
File without changes
|
{dycw_pre_commit_hooks-0.12.6 → dycw_pre_commit_hooks-0.12.8}/src/tests/format_requirements/out.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|