dycw-pre-commit-hooks 0.9.14__tar.gz → 0.9.16__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.

Files changed (29) hide show
  1. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/.pre-commit-config.yaml +4 -2
  2. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/PKG-INFO +1 -1
  3. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/__init__.py +1 -1
  4. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/common.py +2 -8
  5. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/run_bump2version/__init__.py +1 -1
  6. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/run_dockfmt/__init__.py +3 -4
  7. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/run_hatch_version/__init__.py +1 -1
  8. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/run_ruff_format/__init__.py +18 -25
  9. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/run_uv_pip_compile/__init__.py +2 -2
  10. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pyproject.toml +44 -5
  11. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/requirements.txt +34 -26
  12. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/.envrc +0 -0
  13. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/.github/workflows/push.yml +0 -0
  14. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/.gitignore +0 -0
  15. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/.pre-commit-hooks.yaml +0 -0
  16. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/README.md +0 -0
  17. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/py.typed +0 -0
  18. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/run_bump2version/__main__.py +0 -0
  19. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/run_dockfmt/__main__.py +0 -0
  20. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/run_hatch_version/__main__.py +0 -0
  21. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/run_ruff_format/__main__.py +0 -0
  22. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/pre_commit_hooks/run_uv_pip_compile/__main__.py +0 -0
  23. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/tests/__init__.py +0 -0
  24. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/tests/test_main.py +0 -0
  25. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/try-repo/run-bump2version.sh +0 -0
  26. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/try-repo/run-dockfmt.sh +0 -0
  27. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/try-repo/run-hatch-version.sh +0 -0
  28. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/try-repo/run-ruff-format.sh +0 -0
  29. {dycw_pre_commit_hooks-0.9.14 → dycw_pre_commit_hooks-0.9.16}/try-repo/run-uv-pip-compile.sh +0 -0
@@ -1,12 +1,14 @@
1
1
  repos:
2
2
  # fixers
3
3
  - repo: https://github.com/astral-sh/ruff-pre-commit
4
- rev: v0.3.7
4
+ rev: v0.5.1
5
5
  hooks:
6
6
  - id: ruff
7
7
  args: [--fix]
8
+ - id: ruff-format
9
+ types_or: [python, pyi, jupyter]
8
10
  - repo: https://github.com/dycw/pre-commit-hooks
9
- rev: 0.9.13
11
+ rev: 0.9.15
10
12
  hooks:
11
13
  - id: run-hatch-version
12
14
  - id: run-ruff-format
@@ -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
@@ -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
@@ -106,13 +106,40 @@ src = ["src"]
106
106
  target-version = "py310"
107
107
  unsafe-fixes = true
108
108
 
109
+ [tool.ruff.format]
110
+ preview = true
111
+
109
112
  [tool.ruff.lint]
113
+ fixable = ["ALL"]
110
114
  ignore = [
111
115
  "ANN101", # missing-type-self
112
116
  "ANN102", # missing-type-cls
113
- "ANN401", # dynamically-typed-expression
114
- "D", # pydocstyle
117
+ "ANN401", # any-type
118
+ "C901", # complex-structure
119
+ "D100", # undocumented-public-module
120
+ "D101", # undocumented-public-class
121
+ "D102", # undocumented-public-method
122
+ "D103", # undocumented-public-function
123
+ "D104", # undocumented-public-package
124
+ "D105", # undocumented-magic-method
125
+ "D106", # undocumented-public-nested-class
126
+ "D107", # undocumented-public-init
127
+ "D203", # one-blank-line-before-class
128
+ "D213", # multi-line-summary-second-line
129
+ "E501", # line-too-long
130
+ "PD901", # pandas-df-variable-name
131
+ "PERF203", # try-except-in-loop
132
+ "PLR0911", # too-many-return-statements
133
+ "PLR0912", # too-many-branches
134
+ "PLR0913", # too-many-arguments
135
+ "PLR0915", # too-many-statements
136
+ "PLR2004", # magic-value-comparison
115
137
  "PT013", # pytest-incorrect-pytest-import
138
+ "S311", # suspicious-non-cryptographic-random-usage
139
+ "S603", # subprocess-without-shell-equals-true
140
+ "S607", # start-process-with-partial-path
141
+ # preview
142
+ "S101", # assert
116
143
  # formatter
117
144
  "W191", # tab-indentation
118
145
  "E111", # indentation-with-invalid-multiple
@@ -130,17 +157,29 @@ ignore = [
130
157
  "ISC002", # multi-line-implicit-string-concatenation
131
158
  ]
132
159
  select = ["ALL"]
160
+ unfixable = [
161
+ "B007", # unused-loop-control-variable
162
+ "F541", # f-string-missing-placeholders
163
+ "F601", # multi-value-repeated-key-literal
164
+ "PIE794", # duplicate-class-field-definition
165
+ "PLR5501", # collapsible-else-if
166
+ "PT014", # pytest-duplicate-parametrize-test-cases
167
+ "RET504", # unnecessary-assign
168
+ "SIM102", # collapsible-if
169
+ "SIM105", # suppressible-exception
170
+ "SIM114", # if-with-same-arms
171
+ "T201", # print
172
+ ]
133
173
 
134
174
  [tool.ruff.lint.extend-per-file-ignores]
135
175
  "*.ipynb" = [
176
+ "B018", # useless-expression
136
177
  "F403", # undefined-local-with-import-star
137
178
  "F405", # undefined-local-with-import-star-usage
138
179
  "PLE1142", # await-outside-async
180
+ "S101", # assert-used
139
181
  ]
140
182
  "src/tests/**/*.py" = [
141
- "FBT001", # boolean-positional-arg-in-function-definition
142
- "FBT003", # boolean-positional-value-in-function-call
143
- "PLR2004", # magic-value-comparison
144
183
  "S101", # assert-used
145
184
  ]
146
185
 
@@ -1,25 +1,25 @@
1
1
  # This file was autogenerated by uv via the following command:
2
2
  # uv pip compile --extra=dev --prerelease=disallow --output-file=requirements.txt --python-version=3.10 pyproject.toml
3
- anyio==4.3.0
3
+ anyio==4.4.0
4
4
  # via httpx
5
5
  attrs==23.2.0
6
6
  # via hypothesis
7
- backports-tarfile==1.1.0
7
+ backports-tarfile==1.2.0
8
8
  # via jaraco-context
9
- certifi==2024.2.2
9
+ certifi==2024.7.4
10
10
  # via
11
11
  # httpcore
12
12
  # httpx
13
13
  click==8.1.7
14
14
  # via
15
+ # dycw-pre-commit-hooks (pyproject.toml)
15
16
  # hatch
16
17
  # userpath
17
18
  distlib==0.3.8
18
19
  # via virtualenv
19
20
  dycw-utilities==0.25.2
20
- editables==0.5
21
- # via hatchling
22
- exceptiongroup==1.2.0
21
+ # via dycw-pre-commit-hooks (pyproject.toml)
22
+ exceptiongroup==1.2.1
23
23
  # via
24
24
  # anyio
25
25
  # dycw-utilities
@@ -27,12 +27,13 @@ exceptiongroup==1.2.0
27
27
  # pytest
28
28
  execnet==2.1.1
29
29
  # via pytest-xdist
30
- filelock==3.13.4
30
+ filelock==3.15.4
31
31
  # via virtualenv
32
32
  h11==0.14.0
33
33
  # via httpcore
34
- hatch==1.9.4
35
- hatchling==1.21.1
34
+ hatch==1.12.0
35
+ # via dycw-pre-commit-hooks (pyproject.toml)
36
+ hatchling==1.25.0
36
37
  # via hatch
37
38
  httpcore==1.0.5
38
39
  # via httpx
@@ -40,14 +41,14 @@ httpx==0.27.0
40
41
  # via hatch
41
42
  hyperlink==21.0.0
42
43
  # via hatch
43
- hypothesis==6.100.1
44
+ hypothesis==6.105.1
44
45
  # via dycw-utilities
45
46
  idna==3.7
46
47
  # via
47
48
  # anyio
48
49
  # httpx
49
50
  # hyperlink
50
- importlib-metadata==7.1.0
51
+ importlib-metadata==8.0.0
51
52
  # via keyring
52
53
  iniconfig==2.0.0
53
54
  # via pytest
@@ -55,20 +56,21 @@ jaraco-classes==3.4.0
55
56
  # via keyring
56
57
  jaraco-context==5.3.0
57
58
  # via keyring
58
- jaraco-functools==4.0.0
59
+ jaraco-functools==4.0.1
59
60
  # via keyring
60
- keyring==25.1.0
61
+ keyring==25.2.1
61
62
  # via hatch
62
63
  loguru==0.7.2
64
+ # via dycw-pre-commit-hooks (pyproject.toml)
63
65
  markdown-it-py==3.0.0
64
66
  # via rich
65
67
  mdurl==0.1.2
66
68
  # via markdown-it-py
67
- more-itertools==10.2.0
69
+ more-itertools==10.3.0
68
70
  # via
69
71
  # jaraco-classes
70
72
  # jaraco-functools
71
- packaging==24.0
73
+ packaging==24.1
72
74
  # via
73
75
  # hatch
74
76
  # hatchling
@@ -77,30 +79,31 @@ pathspec==0.12.1
77
79
  # via hatchling
78
80
  pexpect==4.9.0
79
81
  # via hatch
80
- platformdirs==4.2.0
82
+ platformdirs==4.2.2
81
83
  # via
82
84
  # hatch
83
85
  # virtualenv
84
- pluggy==1.4.0
86
+ pluggy==1.5.0
85
87
  # via
86
88
  # hatchling
87
89
  # pytest
88
90
  ptyprocess==0.7.0
89
91
  # via pexpect
90
- pygments==2.17.2
92
+ pygments==2.18.0
91
93
  # via rich
92
- pytest==8.1.1
94
+ pytest==8.2.2
93
95
  # via
94
96
  # dycw-utilities
95
97
  # pytest-randomly
96
98
  # pytest-xdist
97
99
  pytest-randomly==3.15.0
98
100
  # via dycw-utilities
99
- pytest-xdist==3.5.0
101
+ pytest-xdist==3.6.1
100
102
  # via dycw-utilities
101
103
  rich==13.7.1
102
104
  # via hatch
103
105
  semver==3.0.2
106
+ # via dycw-pre-commit-hooks (pyproject.toml)
104
107
  shellingham==1.5.4
105
108
  # via hatch
106
109
  sniffio==1.3.1
@@ -115,20 +118,25 @@ tomli==2.0.1
115
118
  # pytest
116
119
  tomli-w==1.0.0
117
120
  # via hatch
118
- tomlkit==0.12.4
119
- # via hatch
120
- trove-classifiers==2024.4.10
121
+ tomlkit==0.12.5
122
+ # via
123
+ # dycw-pre-commit-hooks (pyproject.toml)
124
+ # hatch
125
+ trove-classifiers==2024.7.2
121
126
  # via hatchling
122
- typing-extensions==4.11.0
127
+ typing-extensions==4.12.2
123
128
  # via
124
129
  # anyio
125
130
  # dycw-utilities
126
131
  userpath==1.9.2
127
132
  # via hatch
128
- virtualenv==20.25.3
133
+ uv==0.2.22
134
+ # via hatch
135
+ virtualenv==20.26.3
129
136
  # via hatch
130
137
  xdg-base-dirs==6.0.1
131
- zipp==3.18.1
138
+ # via dycw-pre-commit-hooks (pyproject.toml)
139
+ zipp==3.19.2
132
140
  # via importlib-metadata
133
141
  zstandard==0.22.0
134
142
  # via hatch