dycw-pre-commit-hooks 0.9.24__tar.gz → 0.10.4__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 (38) hide show
  1. dycw_pre_commit_hooks-0.10.4/.envrc +3 -0
  2. dycw_pre_commit_hooks-0.10.4/.github/workflows/pull-request.yml +16 -0
  3. dycw_pre_commit_hooks-0.10.4/.github/workflows/push.yml +38 -0
  4. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/.pre-commit-config.yaml +10 -9
  5. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/.pre-commit-hooks.yaml +23 -0
  6. dycw_pre_commit_hooks-0.10.4/.python-version +1 -0
  7. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/PKG-INFO +2 -6
  8. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/__init__.py +1 -1
  9. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/common.py +25 -12
  10. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/run_bump2version/__init__.py +7 -10
  11. dycw_pre_commit_hooks-0.10.4/pre_commit_hooks/run_bump_my_version/__init__.py +34 -0
  12. dycw_pre_commit_hooks-0.10.4/pre_commit_hooks/run_bump_my_version/__main__.py +6 -0
  13. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/run_hatch_version/__init__.py +1 -1
  14. dycw_pre_commit_hooks-0.10.4/pre_commit_hooks/run_uv_pip_compile/__init__.py +121 -0
  15. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pyproject.toml +22 -13
  16. dycw_pre_commit_hooks-0.10.4/run-test-hook.sh +28 -0
  17. dycw_pre_commit_hooks-0.10.4/uv.lock +551 -0
  18. dycw_pre_commit_hooks-0.9.24/.envrc +0 -2
  19. dycw_pre_commit_hooks-0.9.24/.github/workflows/push.yml +0 -50
  20. dycw_pre_commit_hooks-0.9.24/pre_commit_hooks/run_uv_pip_compile/__init__.py +0 -80
  21. dycw_pre_commit_hooks-0.9.24/requirements.txt +0 -170
  22. dycw_pre_commit_hooks-0.9.24/try-repo/run-bump2version.sh +0 -9
  23. dycw_pre_commit_hooks-0.9.24/try-repo/run-dockfmt.sh +0 -9
  24. dycw_pre_commit_hooks-0.9.24/try-repo/run-hatch-version.sh +0 -9
  25. dycw_pre_commit_hooks-0.9.24/try-repo/run-ruff-format.sh +0 -9
  26. dycw_pre_commit_hooks-0.9.24/try-repo/run-uv-pip-compile.sh +0 -9
  27. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/.gitignore +0 -0
  28. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/README.md +0 -0
  29. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/py.typed +0 -0
  30. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/run_bump2version/__main__.py +0 -0
  31. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/run_dockfmt/__init__.py +0 -0
  32. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/run_dockfmt/__main__.py +0 -0
  33. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/run_hatch_version/__main__.py +0 -0
  34. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/run_ruff_format/__init__.py +0 -0
  35. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/run_ruff_format/__main__.py +0 -0
  36. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/pre_commit_hooks/run_uv_pip_compile/__main__.py +0 -0
  37. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/tests/__init__.py +0 -0
  38. {dycw_pre_commit_hooks-0.9.24 → dycw_pre_commit_hooks-0.10.4}/tests/test_main.py +0 -0
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ use_uv_python
@@ -0,0 +1,16 @@
1
+ name: pull-request
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ lint:
10
+ name: lint
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: astral-sh/ruff-action@v3
15
+ - run: ruff check --fix
16
+ - run: ruff format
@@ -0,0 +1,38 @@
1
+ name: push
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ tag:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: butlerlogic/action-autotag@1.1.2 # https://github.com/ButlerLogic/action-autotag/issues/45#issuecomment-1825726927
14
+ env:
15
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
16
+ with:
17
+ strategy: regex
18
+ root: pyproject.toml
19
+ regex_pattern: 'current_version = "(?<version>\d+\.\d+\.\d+)"'
20
+
21
+ publish:
22
+ runs-on: ubuntu-latest
23
+ needs:
24
+ - tag
25
+ environment:
26
+ name: pypi
27
+ permissions:
28
+ id-token: write
29
+ steps:
30
+ - uses: actions/checkout@v4
31
+ - uses: astral-sh/setup-uv@v5
32
+ with:
33
+ enable-cache: true
34
+ - uses: actions/setup-python@v5
35
+ with:
36
+ python-version-file: pyproject.toml
37
+ - run: uv build
38
+ - run: uv publish --trusted-publishing always
@@ -1,18 +1,23 @@
1
1
  repos:
2
2
  # fixers
3
3
  - repo: https://github.com/astral-sh/ruff-pre-commit
4
- rev: v0.9.3
4
+ rev: v0.9.10
5
5
  hooks:
6
6
  - id: ruff
7
7
  args: [--fix]
8
8
  - id: ruff-format
9
+ - repo: https://github.com/astral-sh/uv-pre-commit
10
+ rev: 0.6.5
11
+ hooks:
12
+ - id: uv-lock
13
+ - id: uv-sync
14
+ args: [--all-packages, --upgrade]
15
+ stages: [post-checkout, post-merge, post-rewrite]
9
16
  - repo: https://github.com/dycw/pre-commit-hooks
10
- rev: 0.9.23
17
+ rev: 0.9.26
11
18
  hooks:
12
- - id: run-hatch-version
19
+ # - id: run-hatch-version
13
20
  - id: run-ruff-format
14
- - id: run-uv-pip-compile
15
- args: [--python-version=3.11]
16
21
  - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
17
22
  rev: v2.14.0
18
23
  hooks:
@@ -40,10 +45,6 @@ repos:
40
45
  - id: no-commit-to-branch
41
46
  - id: trailing-whitespace
42
47
  # linters
43
- - repo: https://github.com/andreoliwa/nitpick
44
- rev: v0.35.0
45
- hooks:
46
- - id: nitpick-check
47
48
  - repo: https://github.com/shellcheck-py/shellcheck-py
48
49
  rev: v0.10.0.1
49
50
  hooks:
@@ -5,6 +5,13 @@
5
5
  always_run: true
6
6
  pass_filenames: false
7
7
  description: Run `bump2version`
8
+ - id: run-bump-my-version
9
+ name: run-bump-my-version
10
+ entry: run-bump-my-version
11
+ language: python
12
+ always_run: true
13
+ pass_filenames: false
14
+ description: Run `bump-my-version`
8
15
  - id: run-dockfmt
9
16
  name: run-dockfmt
10
17
  entry: run-dockfmt
@@ -32,3 +39,19 @@
32
39
  files: ^pyproject\.toml$
33
40
  pass_filenames: false
34
41
  description: Run `uv pip compile`
42
+ - id: test-hook
43
+ name: test-hook
44
+ entry: run-uv-pip-compile
45
+ language: python
46
+ files: ^pyproject\.toml$
47
+ pass_filenames: false
48
+ description: Run `uv pip compile`
49
+ args: [
50
+ # --output-file=requirements-macos.txt,
51
+ # --extra=interactive,
52
+ # --python-platform=macos,
53
+ # --python-version=3.12,
54
+ --output-file=requirements-linux.txt,
55
+ --python-platform=linux,
56
+ --python-version=3.12,
57
+ ]
@@ -0,0 +1 @@
1
+ 3.11
@@ -1,18 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-pre-commit-hooks
3
- Version: 0.9.24
3
+ Version: 0.10.4
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: click<8.2,>=8.1.8
7
- Requires-Dist: dycw-utilities<0.93,>=0.92.10
7
+ Requires-Dist: dycw-utilities<0.96,>=0.95.21
8
8
  Requires-Dist: loguru<0.8,>=0.7.3
9
9
  Requires-Dist: semver<3.1,>=3.0.4
10
10
  Requires-Dist: tomlkit<0.14,>=0.13.2
11
11
  Requires-Dist: xdg-base-dirs<6.1,>=6.0.2
12
- Provides-Extra: dev
13
- Requires-Dist: dycw-utilities[test]; extra == 'dev'
14
- Requires-Dist: hatch<1.15,>=1.14.0; extra == 'dev'
15
- Requires-Dist: setuptools<75.9,>=75.8.0; extra == 'dev'
16
12
  Description-Content-Type: text/markdown
17
13
 
18
14
  # pre-commit-hooks
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.9.24"
3
+ __version__ = "0.10.4"
@@ -18,12 +18,16 @@ PYPROJECT_TOML = _ROOT.joinpath("pyproject.toml")
18
18
  REQUIREMENTS_TXT = _ROOT.joinpath("requirements.txt")
19
19
 
20
20
 
21
+ ##
22
+
23
+
24
+ _VERSION_BUMP_SCRIPTS = Literal[
25
+ "run-bump-my-version", "run-bump2version", "run-hatch-version"
26
+ ]
27
+
28
+
21
29
  def check_versions(
22
- path: Path,
23
- pattern: str,
24
- /,
25
- *,
26
- name: Literal["run-bump2version", "run-hatch-version"],
30
+ path: Path, pattern: str, name: _VERSION_BUMP_SCRIPTS, /
27
31
  ) -> VersionInfo | None:
28
32
  """Check the versions: current & master.
29
33
 
@@ -32,7 +36,7 @@ def check_versions(
32
36
  """
33
37
  with path.open() as fh:
34
38
  current = _parse_version(pattern, fh.read())
35
- master = _get_master_version(path, pattern, name=name)
39
+ master = _get_master_version(name, path, pattern)
36
40
  patched = master.bump_patch()
37
41
  if current in {master.bump_major(), master.bump_minor(), patched}:
38
42
  return None
@@ -46,11 +50,7 @@ def _parse_version(pattern: str, text: str, /) -> VersionInfo:
46
50
 
47
51
 
48
52
  def _get_master_version(
49
- path: Path,
50
- pattern: str,
51
- /,
52
- *,
53
- name: Literal["run-bump2version", "run-hatch-version"],
53
+ name: _VERSION_BUMP_SCRIPTS, path: Path, pattern: str, /
54
54
  ) -> VersionInfo:
55
55
  repo = md5(Path.cwd().as_posix().encode(), usedforsecurity=False).hexdigest()
56
56
  commit = check_output(["git", "rev-parse", "origin/master"], text=True).rstrip("\n")
@@ -67,7 +67,10 @@ def _get_master_version(
67
67
  return version
68
68
 
69
69
 
70
- @dataclass
70
+ ##
71
+
72
+
73
+ @dataclass(kw_only=True)
71
74
  class PyProject:
72
75
  contents: str
73
76
  doc: TOMLDocument
@@ -82,3 +85,13 @@ def read_pyproject() -> PyProject:
82
85
  raise
83
86
  doc = parse(contents)
84
87
  return PyProject(contents=contents, doc=doc)
88
+
89
+
90
+ ##
91
+
92
+
93
+ def trim_trailing_whitespaces(path: Path, /) -> None:
94
+ with path.open() as fh:
95
+ lines = fh.readlines()
96
+ with path.open(mode="w") as fh:
97
+ fh.writelines([line.rstrip(" ") for line in lines])
@@ -7,7 +7,11 @@ from typing import Literal
7
7
  from click import command, option
8
8
  from loguru import logger
9
9
 
10
- from pre_commit_hooks.common import check_versions
10
+ from pre_commit_hooks.common import (
11
+ PYPROJECT_TOML,
12
+ check_versions,
13
+ trim_trailing_whitespaces,
14
+ )
11
15
 
12
16
 
13
17
  @command()
@@ -23,7 +27,7 @@ def main(*, setup_cfg: bool) -> bool:
23
27
  def _process(*, filename: Literal["setup.cfg", ".bumpversion.cfg"]) -> bool:
24
28
  path = Path(filename)
25
29
  pattern = r"current_version = (\d+\.\d+\.\d+)$"
26
- version = check_versions(path, pattern, name="run-bump2version")
30
+ version = check_versions(PYPROJECT_TOML, pattern, "run-bump2version")
27
31
  if version is None:
28
32
  return True
29
33
  cmd = ["bump2version", "--allow-dirty", f"--new-version={version}", "patch"]
@@ -37,13 +41,6 @@ def _process(*, filename: Literal["setup.cfg", ".bumpversion.cfg"]) -> bool:
37
41
  "Failed to run {cmd!r}. Is `bump2version` installed?", cmd=" ".join(cmd)
38
42
  )
39
43
  else:
40
- _trim_trailing_whitespaces(path)
44
+ trim_trailing_whitespaces(path)
41
45
  return True
42
46
  return False
43
-
44
-
45
- def _trim_trailing_whitespaces(path: Path, /) -> None:
46
- with path.open() as fh:
47
- lines = fh.readlines()
48
- with path.open(mode="w") as fh:
49
- fh.writelines([line.rstrip(" ") for line in lines])
@@ -0,0 +1,34 @@
1
+ from __future__ import annotations
2
+
3
+ from subprocess import PIPE, STDOUT, CalledProcessError, check_call
4
+
5
+ from click import command
6
+ from loguru import logger
7
+
8
+ from pre_commit_hooks.common import PYPROJECT_TOML, check_versions
9
+
10
+
11
+ @command()
12
+ def main() -> bool:
13
+ """CLI for the `run_bump_my_version` hook."""
14
+ return _process()
15
+
16
+
17
+ def _process() -> bool:
18
+ pattern = r"current_version = (\d+\.\d+\.\d+)$"
19
+ version = check_versions(PYPROJECT_TOML, pattern, "run-bump-my-version")
20
+ if version is None:
21
+ return True
22
+ cmd = ["bump-my-version", "--allow-dirty", f"--new-version={version}", "patch"]
23
+ try:
24
+ _ = check_call(cmd, stdout=PIPE, stderr=STDOUT)
25
+ except CalledProcessError as error:
26
+ if error.returncode != 1:
27
+ logger.exception("Failed to run {cmd!r}", cmd=" ".join(cmd))
28
+ except FileNotFoundError:
29
+ logger.exception(
30
+ "Failed to run {cmd!r}. Is `bump-my-version` installed?", cmd=" ".join(cmd)
31
+ )
32
+ else:
33
+ return True
34
+ return False
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ from pre_commit_hooks.run_bump_my_version import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(int(not main()))
@@ -20,7 +20,7 @@ def main() -> bool:
20
20
  def _process() -> bool:
21
21
  path = _get_path_version_file()
22
22
  pattern = r'^__version__ = "(\d+\.\d+\.\d+)"$'
23
- version = check_versions(path, pattern, name="run-hatch-version")
23
+ version = check_versions(path, pattern, "run-hatch-version")
24
24
  if version is None:
25
25
  return True
26
26
  cmd = ["hatch", "version", str(version)]
@@ -0,0 +1,121 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+ from re import sub
5
+ from subprocess import CalledProcessError, check_call
6
+ from tempfile import TemporaryDirectory
7
+ from typing import TYPE_CHECKING, Literal
8
+
9
+ from click import Choice, command, option
10
+ from loguru import logger
11
+
12
+ from pre_commit_hooks.common import REQUIREMENTS_TXT
13
+
14
+ if TYPE_CHECKING:
15
+ from collections.abc import Iterable
16
+
17
+
18
+ @command()
19
+ @option(
20
+ "--output-file",
21
+ default=REQUIREMENTS_TXT,
22
+ help="Write the compiled requirements to the given `requirements.txt` file",
23
+ )
24
+ @option("--extra", multiple=True, help="Optional dependencies")
25
+ @option(
26
+ "--python-platform",
27
+ type=Choice(["windows", "linux", "macos"], case_sensitive=False),
28
+ help="The platform for which requirements should be resolved",
29
+ )
30
+ @option(
31
+ "--python-version", default=None, help="The Python version to use for resolution"
32
+ )
33
+ def main(
34
+ *,
35
+ output_file: Path | str = REQUIREMENTS_TXT,
36
+ extra: tuple[str, ...] = (),
37
+ python_platform: Literal["windows", "linux", "macos"] | None = None,
38
+ python_version: str | None = None,
39
+ ) -> bool:
40
+ """CLI for the `run-uv-pip-compile` hook."""
41
+ return _process(
42
+ output_file=Path(output_file),
43
+ extra=None if len(extra) == 0 else list(extra),
44
+ python_platform=python_platform,
45
+ python_version=python_version,
46
+ )
47
+
48
+
49
+ def _process(
50
+ *,
51
+ extra: Iterable[str] | None = None,
52
+ output_file: Path = REQUIREMENTS_TXT,
53
+ python_platform: Literal["windows", "linux", "macos"] | None = None,
54
+ python_version: str | None = None,
55
+ ) -> bool:
56
+ curr = _read_requirements_txt(output_file)
57
+ latest = _run_uv_pip_compile(
58
+ extra=extra, python_platform=python_platform, python_version=python_version
59
+ )
60
+ if curr == latest:
61
+ return True
62
+ _write_requirements_txt(latest, path=output_file)
63
+ return False
64
+
65
+
66
+ def _read_requirements_txt(path: Path, /) -> str | None:
67
+ try:
68
+ with path.open() as fh:
69
+ return fh.read()
70
+ except FileNotFoundError:
71
+ return None
72
+
73
+
74
+ def _run_uv_pip_compile(
75
+ *,
76
+ extra: Iterable[str] | None = None,
77
+ python_platform: Literal["windows", "linux", "macos"] | None = None,
78
+ python_version: str | None = None,
79
+ ) -> str:
80
+ cmd: list[str] = [
81
+ "uv",
82
+ "pip",
83
+ "compile",
84
+ "--extra=dev",
85
+ "--prerelease=explicit",
86
+ "--quiet",
87
+ "--upgrade",
88
+ ]
89
+ if extra is not None:
90
+ cmd.extend(f"--extra={e}" for e in extra)
91
+ if python_platform is not None:
92
+ cmd.append(f"--python-platform={python_platform}")
93
+ if python_version is not None:
94
+ cmd.append(f"--python-version={python_version}")
95
+ with TemporaryDirectory() as temp:
96
+ temp_file = Path(temp, "temp.txt")
97
+ cmd.extend([
98
+ f"--output-file={temp_file.as_posix()}",
99
+ "pyproject.toml", # don't use absolute path
100
+ ])
101
+ try:
102
+ _ = check_call(cmd)
103
+ except CalledProcessError:
104
+ logger.exception("Failed to run {cmd!r}", cmd=" ".join(cmd))
105
+ raise
106
+ with temp_file.open(mode="r") as fh:
107
+ contents = fh.read()
108
+ return _fix_header(contents, temp_file) + "\n"
109
+
110
+
111
+ def _fix_header(text: str, temp_file: Path, /) -> str:
112
+ return "\n".join(_fix_header_line(line, temp_file) for line in text.splitlines())
113
+
114
+
115
+ def _fix_header_line(line: str, temp_file: Path, /) -> str:
116
+ return sub(str(temp_file), temp_file.name, line)
117
+
118
+
119
+ def _write_requirements_txt(contents: str, /, *, path: Path = REQUIREMENTS_TXT) -> None:
120
+ with path.open(mode="w") as fh:
121
+ _ = fh.write(contents)
@@ -1,39 +1,51 @@
1
- # build-system
1
+ #
2
2
 
3
+ # build-system
3
4
  [build-system]
4
5
  build-backend = "hatchling.build"
5
6
  requires = ["hatchling"]
6
7
 
8
+ # dependency groups
9
+ [dependency-groups]
10
+ dev = [
11
+ "dycw-utilities[test]>=0.94.29",
12
+ "setuptools >= 75.9.1", # https://github.com/theY4Kman/pytest-only/issues/14
13
+ ]
14
+
7
15
  # project
8
16
  [project]
9
17
  authors = [{name = "Derek Wan", email = "d.wan@icloud.com"}]
10
18
  dependencies = [
11
19
  "click >= 8.1.8, < 8.2",
12
- "dycw-utilities >= 0.92.10, < 0.93",
20
+ "dycw-utilities >= 0.95.21, < 0.96",
13
21
  "loguru >= 0.7.3, < 0.8",
14
22
  "semver >= 3.0.4, < 3.1",
15
23
  "tomlkit >= 0.13.2, < 0.14",
16
24
  "xdg-base-dirs >= 6.0.2, < 6.1",
17
25
  ]
18
- dynamic = ["version"]
19
26
  name = "dycw-pre-commit-hooks"
20
27
  readme = "README.md"
21
28
  requires-python = ">= 3.11"
22
-
23
- [project.optional-dependencies]
24
- dev = [
25
- "dycw-utilities[test]",
26
- "hatch >= 1.14.0, < 1.15",
27
- "setuptools >= 75.8.0, < 75.9", # https://github.com/theY4Kman/pytest-only/issues/14
28
- ]
29
+ version = "0.10.4"
29
30
 
30
31
  [project.scripts]
32
+ run-bump-my-version = "pre_commit_hooks.run_bump-my-version:main"
31
33
  run-bump2version = "pre_commit_hooks.run_bump2version:main"
32
34
  run-dockfmt = "pre_commit_hooks.run_dockfmt:main"
33
35
  run-hatch-version = "pre_commit_hooks.run_hatch_version:main"
34
36
  run-ruff-format = "pre_commit_hooks.run_ruff_format:main"
35
37
  run-uv-pip-compile = "pre_commit_hooks.run_uv_pip_compile:main"
36
38
 
39
+ # bump-my-version
40
+ [tool.bumpversion]
41
+ allow_dirty = true
42
+ current_version = "0.10.4"
43
+
44
+ [[tool.bumpversion.files]]
45
+ filename = "src/pre_commit_hooks/__init__.py"
46
+ replace = "__version__ = \"{new_version}\""
47
+ search = "__version__ = \"{current_version}\""
48
+
37
49
  # coverage
38
50
  [tool.coverage]
39
51
 
@@ -60,9 +72,6 @@ sources = ["src"]
60
72
  [tool.hatch.build.targets.wheel]
61
73
  packages = ["src/pre_commit_hooks"]
62
74
 
63
- [tool.hatch.version]
64
- path = "src/pre_commit_hooks/__init__.py"
65
-
66
75
  # nitpick
67
76
  [tool.nitpick]
68
77
  style = [
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # usage: edit the following in `.pre-commit-hooks.yaml`
4
+ #
5
+ # - id: test-hook
6
+ # name: test-hook
7
+ # entry: run-uv-pip-compile
8
+ # language: python
9
+ # files: ^pyproject\.toml$
10
+ # pass_filenames: false
11
+ # description: Run `uv pip compile`
12
+ # args: [
13
+ # --output-file=requirements-macos.txt
14
+ # --extra=interactive
15
+ # --python-platform=macos
16
+ # --python-version=3.12,
17
+ # ]
18
+ #
19
+ # then, in your project, run:
20
+ #
21
+ # ❯ ../pre-commit-hooks/run-test-hook.sh
22
+
23
+ PATH_DIR="$(
24
+ cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit
25
+ pwd -P
26
+ )"
27
+
28
+ pre-commit try-repo --verbose --all-files "$PATH_DIR" test-hook