dycw-pre-commit-hooks 0.9.14__py3-none-any.whl → 0.9.16__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.3
2
2
  Name: dycw-pre-commit-hooks
3
- Version: 0.9.14
3
+ Version: 0.9.16
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: click<8.2,>=8.1.7
@@ -0,0 +1,17 @@
1
+ pre_commit_hooks/__init__.py,sha256=ZHD0SBJW8gRohMGdh9l-NQb9Maq3k_x_DBAZeY9BYn4,59
2
+ pre_commit_hooks/common.py,sha256=H8RJkUXKQ7vHbCsi6oDq7XAdggjOij5R1xGoQ1UXhKA,2512
3
+ pre_commit_hooks/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ pre_commit_hooks/run_bump2version/__init__.py,sha256=nhJ2kdUjSteGVjatTfMSeQb92zIlfiwyeHll_7_nzvM,1581
5
+ pre_commit_hooks/run_bump2version/__main__.py,sha256=BZy8mDElAK3-X2iKvqg1XnGbCiYXcLoMDefaPanWx4g,153
6
+ pre_commit_hooks/run_dockfmt/__init__.py,sha256=REJG8A77H1VbPvIhStlsIWEqqYeaK4h7q17kbLTK3TE,1070
7
+ pre_commit_hooks/run_dockfmt/__main__.py,sha256=aE0DIrzWy4mnQ04_n5U6znbmJwJBkjZUXv9Th3OqQ7Y,148
8
+ pre_commit_hooks/run_hatch_version/__init__.py,sha256=EYxh9yJP3axGNASWC5KaKkWhWocNynLiMPUSIGsG4yo,1709
9
+ pre_commit_hooks/run_hatch_version/__main__.py,sha256=XeMLmgm1HMujkYhaF9LcMygBrwa2KqIGMzznY106gd8,154
10
+ pre_commit_hooks/run_ruff_format/__init__.py,sha256=Lr_9M0WHhJl6WARAf8Lr830PG9bMbkDXvNSmEkrSxK8,1993
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=FwHYh0fvkYckgminkzih_uMGjOJXXpwT8rkuyrfkuFE,2368
13
+ pre_commit_hooks/run_uv_pip_compile/__main__.py,sha256=LLlM3xVN7l5cxZ0yD_8He8n_GEmQqn_d-2wl6BQtqoA,155
14
+ dycw_pre_commit_hooks-0.9.16.dist-info/METADATA,sha256=4JuIJRasH_gsOaSBvZPqPCt5Cxrhr4vLRR95BVWkjIg,1120
15
+ dycw_pre_commit_hooks-0.9.16.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
16
+ dycw_pre_commit_hooks-0.9.16.dist-info/entry_points.txt,sha256=E5ZGYo3x6IF71IHDEhXJYfTHRRIrjzzuxsiYgVkCDQE,302
17
+ dycw_pre_commit_hooks-0.9.16.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.24.0
2
+ Generator: hatchling 1.25.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.9.14"
3
+ __version__ = "0.9.16"
@@ -53,20 +53,14 @@ def _get_master_version(
53
53
  name: Literal["run-bump2version", "run-hatch-version"],
54
54
  ) -> VersionInfo:
55
55
  repo = md5(Path.cwd().as_posix().encode(), usedforsecurity=False).hexdigest()
56
- commit = check_output(
57
- ["git", "rev-parse", "origin/master"], # noqa: S603, S607
58
- text=True,
59
- ).rstrip("\n")
56
+ commit = check_output(["git", "rev-parse", "origin/master"], text=True).rstrip("\n")
60
57
  cache = xdg_cache_home().joinpath("pre-commit-hooks", name, repo, commit)
61
58
  try:
62
59
  with cache.open() as fh:
63
60
  return VersionInfo.parse(fh.read())
64
61
  except FileNotFoundError:
65
62
  cache.parent.mkdir(parents=True, exist_ok=True)
66
- text = check_output(
67
- ["git", "show", f"{commit}:{path}"], # noqa: S603, S607
68
- text=True,
69
- )
63
+ text = check_output(["git", "show", f"{commit}:{path}"], text=True)
70
64
  version = _parse_version(pattern, text)
71
65
  with cache.open(mode="w") as fh:
72
66
  _ = fh.write(str(version))
@@ -28,7 +28,7 @@ def _process(*, filename: Literal["setup.cfg", ".bumpversion.cfg"]) -> bool:
28
28
  return True
29
29
  cmd = ["bump2version", "--allow-dirty", f"--new-version={version}", "patch"]
30
30
  try:
31
- _ = check_call(cmd, stdout=PIPE, stderr=STDOUT) # noqa: S603
31
+ _ = check_call(cmd, stdout=PIPE, stderr=STDOUT)
32
32
  except CalledProcessError as error:
33
33
  if error.returncode != 1:
34
34
  logger.exception("Failed to run {cmd!r}", cmd=" ".join(cmd))
@@ -35,10 +35,9 @@ def _process(path: Path, /) -> bool:
35
35
  with path.open() as fh:
36
36
  current = fh.read()
37
37
  strip = "\t\n"
38
- proposed = check_output(
39
- ["dockfmt", "fmt", path.as_posix()], # noqa: S603, S607
40
- text=True,
41
- ).lstrip(strip)
38
+ proposed = check_output(["dockfmt", "fmt", path.as_posix()], text=True).lstrip(
39
+ strip
40
+ )
42
41
  if current == proposed:
43
42
  return True
44
43
  with path.open(mode="w") as fh:
@@ -25,7 +25,7 @@ def _process() -> bool:
25
25
  return True
26
26
  cmd = ["hatch", "version", str(version)]
27
27
  try:
28
- _ = check_call(cmd, stdout=PIPE, stderr=STDOUT) # noqa: S603
28
+ _ = check_call(cmd, stdout=PIPE, stderr=STDOUT)
29
29
  except CalledProcessError as error:
30
30
  if error.returncode != 1:
31
31
  logger.exception("Failed to run {cmd!r}", cmd=" ".join(cmd))
@@ -1,18 +1,14 @@
1
1
  from __future__ import annotations
2
2
 
3
- from contextlib import contextmanager
4
3
  from subprocess import CalledProcessError, check_call
5
- from typing import TYPE_CHECKING, cast
4
+ from typing import cast
6
5
 
7
6
  from click import command
8
7
  from loguru import logger
9
- from tomlkit import TOMLDocument, dumps, table
8
+ from tomlkit import dumps, table
10
9
  from tomlkit.container import Container
11
10
 
12
- from pre_commit_hooks.common import PYPROJECT_TOML, read_pyproject
13
-
14
- if TYPE_CHECKING:
15
- from collections.abc import Iterator
11
+ from pre_commit_hooks.common import PYPROJECT_TOML, PyProject, read_pyproject
16
12
 
17
13
 
18
14
  @command()
@@ -22,24 +18,15 @@ def main() -> bool:
22
18
 
23
19
 
24
20
  def _process() -> bool:
25
- with _yield_modified_pyproject():
26
- result1 = _run_ruff_format()
27
- result2 = _run_ruff_format()
28
- return result1 and result2
29
-
30
-
31
- @contextmanager
32
- def _yield_modified_pyproject() -> Iterator[None]:
33
21
  curr = read_pyproject()
34
22
  new = _get_modified_pyproject()
35
- with PYPROJECT_TOML.open(mode="w") as fh:
36
- _ = fh.write(dumps(new))
37
- yield
38
- with PYPROJECT_TOML.open(mode="w") as fh:
39
- _ = fh.write(curr.contents)
23
+ result1 = _run_ruff_format(new)
24
+ result2 = _run_ruff_format(curr)
25
+ _write_pyproject(curr)
26
+ return result1 and result2
40
27
 
41
28
 
42
- def _get_modified_pyproject() -> TOMLDocument:
29
+ def _get_modified_pyproject() -> PyProject:
43
30
  pyproject = read_pyproject()
44
31
  doc = pyproject.doc
45
32
  try:
@@ -70,14 +57,20 @@ def _get_modified_pyproject() -> TOMLDocument:
70
57
  ruff["format"] = format_
71
58
  ruff["lint"] = lint
72
59
  lint["isort"] = isort
73
- return doc
60
+ return PyProject(contents=dumps(doc), doc=doc)
74
61
 
75
62
 
76
- def _run_ruff_format() -> bool:
63
+ def _run_ruff_format(pyproject: PyProject, /) -> bool:
64
+ _write_pyproject(pyproject)
77
65
  cmd = ["ruff", "format", "."]
78
66
  try:
79
- code = check_call(cmd) # noqa: S603
67
+ code = check_call(cmd)
80
68
  except CalledProcessError:
81
69
  logger.exception("Failed to run {cmd!r}", cmd=" ".join(cmd))
82
- raise
70
+ return False
83
71
  return code == 0
72
+
73
+
74
+ def _write_pyproject(pyproject: PyProject, /) -> None:
75
+ with PYPROJECT_TOML.open(mode="w") as fh:
76
+ _ = fh.write(pyproject.contents)
@@ -14,7 +14,7 @@ from pre_commit_hooks.common import REQUIREMENTS_TXT
14
14
  @command()
15
15
  @option(
16
16
  "--python-version",
17
- help="The minimum Python version that should be supported by the compiled requirements", # noqa: E501
17
+ help="The minimum Python version that should be supported by the compiled requirements",
18
18
  )
19
19
  def main(*, python_version: str | None) -> bool:
20
20
  """CLI for the `run-uv-pip-compile` hook."""
@@ -58,7 +58,7 @@ def _run_uv_pip_compile(*, python_version: str | None) -> str:
58
58
  ]
59
59
  )
60
60
  try:
61
- _ = check_call(cmd) # noqa: S603
61
+ _ = check_call(cmd)
62
62
  except CalledProcessError:
63
63
  logger.exception("Failed to run {cmd!r}", cmd=" ".join(cmd))
64
64
  raise
@@ -1,17 +0,0 @@
1
- pre_commit_hooks/__init__.py,sha256=yftzA03Q9wE_I5_e2JF45rmyD7ViurTGTnK3aBqnDcA,59
2
- pre_commit_hooks/common.py,sha256=bgZXq2Mo23RgZdrR4meJRNz0c9eh7AB2VUN8sE8l_gY,2610
3
- pre_commit_hooks/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- pre_commit_hooks/run_bump2version/__init__.py,sha256=IN7eDW_w8uW7KHWZEEi1CiWXoKYeMKEM1AfXOLZ2BoY,1595
5
- pre_commit_hooks/run_bump2version/__main__.py,sha256=BZy8mDElAK3-X2iKvqg1XnGbCiYXcLoMDefaPanWx4g,153
6
- pre_commit_hooks/run_dockfmt/__init__.py,sha256=szZ-M97sM300ZrEqrWxH9B3i6PZPsjuK-NExDFIHd5k,1099
7
- pre_commit_hooks/run_dockfmt/__main__.py,sha256=aE0DIrzWy4mnQ04_n5U6znbmJwJBkjZUXv9Th3OqQ7Y,148
8
- pre_commit_hooks/run_hatch_version/__init__.py,sha256=Ctb1GYz3XTB4vE2gOV_zGVDtDIdM7Heajb25tF19TzA,1723
9
- pre_commit_hooks/run_hatch_version/__main__.py,sha256=XeMLmgm1HMujkYhaF9LcMygBrwa2KqIGMzznY106gd8,154
10
- pre_commit_hooks/run_ruff_format/__init__.py,sha256=J8Eil9zhahRB9GUG8SWdIEM0eIvUmY8Am-W4F-E-4vE,2132
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=FsDDXQZEZF134Bnm7nHjFE2O-fEhkWxk5iFccOQ3cSw,2396
13
- pre_commit_hooks/run_uv_pip_compile/__main__.py,sha256=LLlM3xVN7l5cxZ0yD_8He8n_GEmQqn_d-2wl6BQtqoA,155
14
- dycw_pre_commit_hooks-0.9.14.dist-info/METADATA,sha256=37Z_nI0CMsdM5AmkvJ7Hsd5XuLHWiWYlGK2Rf3dAT5M,1120
15
- dycw_pre_commit_hooks-0.9.14.dist-info/WHEEL,sha256=K0BPUNF1N3kQ9olb8aVEtkObePEjdr2JOLT1N83EVws,87
16
- dycw_pre_commit_hooks-0.9.14.dist-info/entry_points.txt,sha256=E5ZGYo3x6IF71IHDEhXJYfTHRRIrjzzuxsiYgVkCDQE,302
17
- dycw_pre_commit_hooks-0.9.14.dist-info/RECORD,,