dycw-pre-commit-hooks 0.9.15__py3-none-any.whl → 0.9.17__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,17 +1,18 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dycw-pre-commit-hooks
3
- Version: 0.9.15
3
+ Version: 0.9.17
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
- Requires-Python: >=3.10
5
+ Requires-Python: >=3.11
6
6
  Requires-Dist: click<8.2,>=8.1.7
7
- Requires-Dist: dycw-utilities<0.26,>=0.25.1
7
+ Requires-Dist: dycw-utilities<0.41,>=0.40.12
8
8
  Requires-Dist: loguru<0.8,>=0.7.2
9
9
  Requires-Dist: semver<3.1,>=3.0.2
10
- Requires-Dist: tomlkit<0.13,>=0.12.3
10
+ Requires-Dist: tomlkit<0.14,>=0.13.2
11
11
  Requires-Dist: xdg-base-dirs<6.1,>=6.0.1
12
12
  Provides-Extra: dev
13
+ Requires-Dist: basedpyright<1.17,>=1.16.0; extra == 'dev'
13
14
  Requires-Dist: dycw-utilities[test]; extra == 'dev'
14
- Requires-Dist: hatch; extra == 'dev'
15
+ Requires-Dist: hatch<1.13,>=1.12.0; extra == 'dev'
15
16
  Description-Content-Type: text/markdown
16
17
 
17
18
  # pre-commit-hooks
@@ -1,17 +1,17 @@
1
- pre_commit_hooks/__init__.py,sha256=v3H64hWnOzKsfkkLGVh7U9nhAg_Lp2a6Xz-jg-BwqdQ,59
1
+ pre_commit_hooks/__init__.py,sha256=fkj2zuGNfek2cfkK31Q9jbw5zfnkaz4jxBR9alDoIE4,59
2
2
  pre_commit_hooks/common.py,sha256=H8RJkUXKQ7vHbCsi6oDq7XAdggjOij5R1xGoQ1UXhKA,2512
3
3
  pre_commit_hooks/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pre_commit_hooks/run_bump2version/__init__.py,sha256=nhJ2kdUjSteGVjatTfMSeQb92zIlfiwyeHll_7_nzvM,1581
5
5
  pre_commit_hooks/run_bump2version/__main__.py,sha256=BZy8mDElAK3-X2iKvqg1XnGbCiYXcLoMDefaPanWx4g,153
6
6
  pre_commit_hooks/run_dockfmt/__init__.py,sha256=REJG8A77H1VbPvIhStlsIWEqqYeaK4h7q17kbLTK3TE,1070
7
7
  pre_commit_hooks/run_dockfmt/__main__.py,sha256=aE0DIrzWy4mnQ04_n5U6znbmJwJBkjZUXv9Th3OqQ7Y,148
8
- pre_commit_hooks/run_hatch_version/__init__.py,sha256=EYxh9yJP3axGNASWC5KaKkWhWocNynLiMPUSIGsG4yo,1709
8
+ pre_commit_hooks/run_hatch_version/__init__.py,sha256=bADWwm3tTgUrDMynBag2Z_hVknlbfOsoYl7ghxTc_hY,1714
9
9
  pre_commit_hooks/run_hatch_version/__main__.py,sha256=XeMLmgm1HMujkYhaF9LcMygBrwa2KqIGMzznY106gd8,154
10
- pre_commit_hooks/run_ruff_format/__init__.py,sha256=rolxkdz2nOxu3gvB143z91PPdqJVsz2pvBD3YD7LXL8,2118
10
+ pre_commit_hooks/run_ruff_format/__init__.py,sha256=Lr_9M0WHhJl6WARAf8Lr830PG9bMbkDXvNSmEkrSxK8,1993
11
11
  pre_commit_hooks/run_ruff_format/__main__.py,sha256=faesqqpMaesg5r-LvkkQt1W9kahvNr-60K3SMYv1NgY,152
12
12
  pre_commit_hooks/run_uv_pip_compile/__init__.py,sha256=FwHYh0fvkYckgminkzih_uMGjOJXXpwT8rkuyrfkuFE,2368
13
13
  pre_commit_hooks/run_uv_pip_compile/__main__.py,sha256=LLlM3xVN7l5cxZ0yD_8He8n_GEmQqn_d-2wl6BQtqoA,155
14
- dycw_pre_commit_hooks-0.9.15.dist-info/METADATA,sha256=zZuzBFcd69XeGtbiRthZqU_ZR1lOLH7800TdC4_SO4c,1120
15
- dycw_pre_commit_hooks-0.9.15.dist-info/WHEEL,sha256=osohxoshIHTFJFVPhsi1UkZuLRGMHRXZzwEBW2ezjrc,87
16
- dycw_pre_commit_hooks-0.9.15.dist-info/entry_points.txt,sha256=E5ZGYo3x6IF71IHDEhXJYfTHRRIrjzzuxsiYgVkCDQE,302
17
- dycw_pre_commit_hooks-0.9.15.dist-info/RECORD,,
14
+ dycw_pre_commit_hooks-0.9.17.dist-info/METADATA,sha256=BbBu0x_zwGC_6uK7eB3F-XK1L-q8GzUgxp9Ttb1qVSQ,1193
15
+ dycw_pre_commit_hooks-0.9.17.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
16
+ dycw_pre_commit_hooks-0.9.17.dist-info/entry_points.txt,sha256=E5ZGYo3x6IF71IHDEhXJYfTHRRIrjzzuxsiYgVkCDQE,302
17
+ dycw_pre_commit_hooks-0.9.17.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.24.1
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.15"
3
+ __version__ = "0.9.17"
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from pathlib import Path
4
4
  from subprocess import PIPE, STDOUT, CalledProcessError, check_call
5
- from typing import cast
5
+ from typing import Any, cast
6
6
 
7
7
  from click import command
8
8
  from loguru import logger
@@ -55,4 +55,4 @@ def _get_path_version_file() -> Path:
55
55
  except KeyError:
56
56
  logger.exception('pyproject.toml has no "tool.hatch.version" section')
57
57
  raise
58
- return Path(cast(str, version["path"]))
58
+ return Path(cast(Any, version["path"]))
@@ -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
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)