dycw-pre-commit-hooks 0.12.5__py3-none-any.whl → 0.12.7__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-pre-commit-hooks
3
- Version: 0.12.5
3
+ Version: 0.12.7
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: click<8.3,>=8.2.1
@@ -8,6 +8,7 @@ Requires-Dist: dycw-utilities<0.167,>=0.166.5
8
8
  Requires-Dist: gitpython<3.2,>=3.1.45
9
9
  Requires-Dist: libcst<1.9,>=1.8.2
10
10
  Requires-Dist: loguru<0.8,>=0.7.3
11
+ Requires-Dist: more-itertools<10.8,>=10.7.0
11
12
  Requires-Dist: orjson<3.12,>=3.11.3
12
13
  Requires-Dist: packaging<25.1,>=25.0
13
14
  Requires-Dist: tomlkit<0.14,>=0.13.2
@@ -1,17 +1,19 @@
1
- pre_commit_hooks/__init__.py,sha256=F3qvvaYWO9UbSdbCiBLQFrc_LvSR0D1M5LVTfyR9LV8,59
1
+ pre_commit_hooks/__init__.py,sha256=k8ybRG68OSwfpxRDPooKpR7wi__uNTKCYPH-LVQBSsc,59
2
2
  pre_commit_hooks/common.py,sha256=Ovg0kK5CBSBEalGdVxLKjvRX3gbjpzTFRNRopB8tEiw,4247
3
3
  pre_commit_hooks/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pre_commit_hooks/check_submodules/__init__.py,sha256=8aJ6sbDclOML5uahK4TNf80Sxf6gCx1kIOYwkv37g9s,1092
5
5
  pre_commit_hooks/check_submodules/__main__.py,sha256=foSVebwCfSkKcAc3cD5YTzkmrWd7Wso9_mR9-zuyG-o,153
6
6
  pre_commit_hooks/format_requirements/__init__.py,sha256=dORQ5sNZaOWYY6cw0X1YIic4OHZeTt9EhI21D1uQFyE,3322
7
7
  pre_commit_hooks/format_requirements/__main__.py,sha256=15JSp_rhjI_Ddoj4MRkHFShfnYxs6GggUhLRlGtrQ0E,156
8
+ pre_commit_hooks/mirror_files/__init__.py,sha256=jJkRsStDwGjDp34T2zO78VmwQsjhyCKZgUmXzOp6J14,1369
9
+ pre_commit_hooks/mirror_files/__main__.py,sha256=YzOSNKR2XrVST5dgIVJrpRL28QkcziciOomuKtVX7Jo,149
8
10
  pre_commit_hooks/replace_sequence_str/__init__.py,sha256=nDjiKV14th2uWbnte1rSvXckysl7ooaLgWo6IP4HI2s,1618
9
11
  pre_commit_hooks/replace_sequence_str/__main__.py,sha256=B1dxOxngV4vUVnDVrXSywiySOs1P_zF30_4ZMRsOSaY,157
10
12
  pre_commit_hooks/run_bump_my_version/__init__.py,sha256=OsMY0boz3VTqAtgLCHtC8AvCXx6OYvOXA5H-VAwBFoY,1444
11
13
  pre_commit_hooks/run_bump_my_version/__main__.py,sha256=w2V3y61jrSau-zxjl8ciHtWPlJQwXbYxNJ2tGYVyI4s,156
12
14
  pre_commit_hooks/tag_commits/__init__.py,sha256=097p0gfZcykpOPUgGYsrLePe8Nar04eKlCMn_mqPepg,2945
13
15
  pre_commit_hooks/tag_commits/__main__.py,sha256=qefgYw7LWbvmzZS45-ym6olS4cHqw1Emw2wlqZBXN_o,148
14
- dycw_pre_commit_hooks-0.12.5.dist-info/METADATA,sha256=d0hMyN0LUeu1JKiAOrSzd91hc-iWSAqD5KnUKrdi1Xk,1061
15
- dycw_pre_commit_hooks-0.12.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- dycw_pre_commit_hooks-0.12.5.dist-info/entry_points.txt,sha256=LqAiEwyqmkYt_sdzcFYgmDZ1Y6exFIwoVWWl8a0vVjU,318
17
- dycw_pre_commit_hooks-0.12.5.dist-info/RECORD,,
16
+ dycw_pre_commit_hooks-0.12.7.dist-info/METADATA,sha256=T7AJVe9SivCfftE5DwNATWO7KJ72wHSeFPHypG7xojE,1105
17
+ dycw_pre_commit_hooks-0.12.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ dycw_pre_commit_hooks-0.12.7.dist-info/entry_points.txt,sha256=0xGzim6HTjeOXJpusYjBk0aEYkXQR2IwrmfzM6KT_r0,368
19
+ dycw_pre_commit_hooks-0.12.7.dist-info/RECORD,,
@@ -1,6 +1,7 @@
1
1
  [console_scripts]
2
2
  check-submodules = pre_commit_hooks.check_submodules:main
3
3
  format-requirements = pre_commit_hooks.format_requirements:main
4
+ mirror-files = pre_commit_hooks.mirror_files:main
4
5
  replace-sequence-str = pre_commit_hooks.replace_sequence_str:main
5
6
  run-bump-my-version = pre_commit_hooks.run_bump_my_version:main
6
7
  tag-commits = pre_commit_hooks.tag_commits:main
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.12.5"
3
+ __version__ = "0.12.7"
@@ -0,0 +1,47 @@
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
+ 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
+ text_from, text_to = path_from.read_text(), path_to.read_text()
40
+ if text_from == text_to:
41
+ return True
42
+ with writer(path_to, overwrite=True) as temp:
43
+ _ = temp.write_text(text_from)
44
+ return False
45
+
46
+
47
+ __all__ = ["main"]
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ from pre_commit_hooks.mirror_files import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(int(not main()))