dycw-pre-commit-hooks 0.10.19__tar.gz → 0.10.21__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.10.19 → dycw_pre_commit_hooks-0.10.21}/PKG-INFO +2 -7
  2. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21}/README.md +1 -6
  3. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21}/pyproject.toml +4 -7
  4. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/pre_commit_hooks/__init__.py +1 -1
  5. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/pre_commit_hooks/common.py +0 -1
  6. dycw_pre_commit_hooks-0.10.19/.envrc +0 -3
  7. dycw_pre_commit_hooks-0.10.19/.github/workflows/pull-request.yml +0 -16
  8. dycw_pre_commit_hooks-0.10.19/.github/workflows/push.yml +0 -38
  9. dycw_pre_commit_hooks-0.10.19/.pre-commit-config.yaml +0 -46
  10. dycw_pre_commit_hooks-0.10.19/.pre-commit-hooks.yaml +0 -57
  11. dycw_pre_commit_hooks-0.10.19/.python-version +0 -1
  12. dycw_pre_commit_hooks-0.10.19/pre_commit_hooks/run_dockfmt/__init__.py +0 -45
  13. dycw_pre_commit_hooks-0.10.19/pre_commit_hooks/run_dockfmt/__main__.py +0 -6
  14. dycw_pre_commit_hooks-0.10.19/pre_commit_hooks/run_hatch_version/__init__.py +0 -58
  15. dycw_pre_commit_hooks-0.10.19/pre_commit_hooks/run_hatch_version/__main__.py +0 -6
  16. dycw_pre_commit_hooks-0.10.19/pre_commit_hooks/run_uv_pip_compile/__init__.py +0 -121
  17. dycw_pre_commit_hooks-0.10.19/pre_commit_hooks/run_uv_pip_compile/__main__.py +0 -6
  18. dycw_pre_commit_hooks-0.10.19/run-test-hook.sh +0 -28
  19. dycw_pre_commit_hooks-0.10.19/uv.lock +0 -1857
  20. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21}/.gitignore +0 -0
  21. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/pre_commit_hooks/py.typed +0 -0
  22. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/pre_commit_hooks/run_bump2version/__init__.py +0 -0
  23. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/pre_commit_hooks/run_bump2version/__main__.py +0 -0
  24. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/pre_commit_hooks/run_bump_my_version/__init__.py +0 -0
  25. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/pre_commit_hooks/run_bump_my_version/__main__.py +0 -0
  26. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/pre_commit_hooks/run_ruff_format/__init__.py +0 -0
  27. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/pre_commit_hooks/run_ruff_format/__main__.py +0 -0
  28. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/tests/__init__.py +0 -0
  29. {dycw_pre_commit_hooks-0.10.19 → dycw_pre_commit_hooks-0.10.21/src}/tests/test_main.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-pre-commit-hooks
3
- Version: 0.10.19
3
+ Version: 0.10.21
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
@@ -29,13 +29,8 @@ My [`pre-commit`](https://pre-commit.com/) hooks.
29
29
  - repo: https://github.com/dycw/pre-commit-hooks
30
30
  rev: master
31
31
  hooks:
32
- - id: run-bump2version
33
- args: [--setup-cfg]
34
- - id: run-dockfmt
35
- - id: run-hatch-version
32
+ - id: run-bump-my-version
36
33
  - id: run-ruff-format
37
- - id: run-uv-pip-compile
38
- args: [--python-version=3.9]
39
34
  ```
40
35
 
41
36
  1. Update your `.pre-commit-config.yaml`:
@@ -15,13 +15,8 @@ My [`pre-commit`](https://pre-commit.com/) hooks.
15
15
  - repo: https://github.com/dycw/pre-commit-hooks
16
16
  rev: master
17
17
  hooks:
18
- - id: run-bump2version
19
- args: [--setup-cfg]
20
- - id: run-dockfmt
21
- - id: run-hatch-version
18
+ - id: run-bump-my-version
22
19
  - id: run-ruff-format
23
- - id: run-uv-pip-compile
24
- args: [--python-version=3.9]
25
20
  ```
26
21
 
27
22
  1. Update your `.pre-commit-config.yaml`:
@@ -27,20 +27,17 @@ dependencies = [
27
27
  name = "dycw-pre-commit-hooks"
28
28
  readme = "README.md"
29
29
  requires-python = ">= 3.11"
30
- version = "0.10.19"
30
+ version = "0.10.21"
31
31
 
32
32
  [project.scripts]
33
33
  run-bump-my-version = "pre_commit_hooks.run_bump_my_version:main"
34
34
  run-bump2version = "pre_commit_hooks.run_bump2version:main"
35
- run-dockfmt = "pre_commit_hooks.run_dockfmt:main"
36
- run-hatch-version = "pre_commit_hooks.run_hatch_version:main"
37
35
  run-ruff-format = "pre_commit_hooks.run_ruff_format:main"
38
- run-uv-pip-compile = "pre_commit_hooks.run_uv_pip_compile:main"
39
36
 
40
37
  # bump-my-version
41
38
  [tool.bumpversion]
42
39
  allow_dirty = true
43
- current_version = "0.10.19"
40
+ current_version = "0.10.21"
44
41
 
45
42
  [[tool.bumpversion.files]]
46
43
  filename = "src/pre_commit_hooks/__init__.py"
@@ -67,8 +64,8 @@ parallel = true
67
64
  # hatch
68
65
  [tool.hatch]
69
66
 
70
- [tool.hatch.build]
71
- sources = ["src"]
67
+ [tool.hatch.build.targets.sdist]
68
+ include = ["src"]
72
69
 
73
70
  [tool.hatch.build.targets.wheel]
74
71
  packages = ["src/pre_commit_hooks"]
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.10.19"
3
+ __version__ = "0.10.21"
@@ -15,7 +15,6 @@ from xdg_base_dirs import xdg_cache_home
15
15
 
16
16
  _ROOT = get_repo_root()
17
17
  PYPROJECT_TOML = _ROOT.joinpath("pyproject.toml")
18
- REQUIREMENTS_TXT = _ROOT.joinpath("requirements.txt")
19
18
 
20
19
 
21
20
  ##
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- use_uv_python
@@ -1,16 +0,0 @@
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
@@ -1,38 +0,0 @@
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,46 +0,0 @@
1
- repos:
2
- # fixers
3
- - repo: https://github.com/astral-sh/ruff-pre-commit
4
- rev: v0.9.10
5
- hooks:
6
- - id: ruff
7
- args: [--fix]
8
- - repo: https://github.com/dycw/pre-commit-hooks
9
- rev: 0.10.14
10
- hooks:
11
- - id: run-bump-my-version
12
- - id: run-ruff-format
13
- - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
14
- rev: v2.14.0
15
- hooks:
16
- - id: pretty-format-toml
17
- args: [--autofix, --trailing-commas]
18
- - repo: https://github.com/astral-sh/uv-pre-commit
19
- rev: 0.6.5
20
- hooks:
21
- - id: uv-sync # after version bump
22
- args: [--all-packages, --upgrade]
23
- stages: [pre-commit, pre-push]
24
- # linters
25
- - repo: https://github.com/andreoliwa/nitpick
26
- rev: v0.35.0
27
- hooks:
28
- - id: nitpick-check
29
- - repo: https://github.com/shellcheck-py/shellcheck-py
30
- rev: v0.10.0.1
31
- hooks:
32
- - id: shellcheck
33
- # fixers/linters
34
- - repo: https://github.com/pre-commit/pre-commit-hooks
35
- rev: v5.0.0
36
- hooks:
37
- - id: check-executables-have-shebangs
38
- - id: check-merge-conflict
39
- - id: check-symlinks
40
- - id: destroyed-symlinks
41
- - id: detect-private-key
42
- - id: end-of-file-fixer
43
- - id: mixed-line-ending
44
- args: [--fix=lf]
45
- - id: no-commit-to-branch
46
- - id: trailing-whitespace
@@ -1,57 +0,0 @@
1
- - id: run-bump2version
2
- name: run-bump2version
3
- entry: run-bump2version
4
- language: python
5
- always_run: true
6
- pass_filenames: false
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`
15
- - id: run-dockfmt
16
- name: run-dockfmt
17
- entry: run-dockfmt
18
- language: python
19
- files: Dockerfile
20
- description: Run `dockfmt`
21
- - id: run-hatch-version
22
- name: run-hatch-version
23
- entry: run-hatch-version
24
- language: python
25
- always_run: true
26
- pass_filenames: false
27
- description: Run `hatch version bump/minor/major`
28
- - id: run-ruff-format
29
- name: run-ruff-format
30
- entry: run-ruff-format
31
- language: python
32
- always_run: true
33
- pass_filenames: false
34
- description: Run `ruff format`
35
- - id: run-uv-pip-compile
36
- name: run-uv-pip-compile
37
- entry: run-uv-pip-compile
38
- language: python
39
- files: ^pyproject\.toml$
40
- pass_filenames: false
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
- ]
@@ -1 +0,0 @@
1
- 3.11
@@ -1,45 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pathlib import Path
4
- from subprocess import check_output
5
- from typing import TYPE_CHECKING
6
-
7
- import click
8
- from click import argument, command
9
-
10
- if TYPE_CHECKING:
11
- from collections.abc import Iterator
12
-
13
-
14
- @command()
15
- @argument(
16
- "paths",
17
- nargs=-1,
18
- type=click.Path(
19
- exists=True, file_okay=True, dir_okay=False, readable=True, path_type=Path
20
- ),
21
- )
22
- def main(paths: tuple[Path, ...], /) -> bool:
23
- """CLI for the `run-dockfmt` hook."""
24
- results = list(_yield_outcomes(*paths)) # run all
25
- return all(results)
26
-
27
-
28
- def _yield_outcomes(*paths: Path) -> Iterator[bool]:
29
- for path in paths:
30
- if path.name == "Dockerfile":
31
- yield _process(path)
32
-
33
-
34
- def _process(path: Path, /) -> bool:
35
- with path.open() as fh:
36
- current = fh.read()
37
- strip = "\t\n"
38
- proposed = check_output(["dockfmt", "fmt", path.as_posix()], text=True).lstrip(
39
- strip
40
- )
41
- if current == proposed:
42
- return True
43
- with path.open(mode="w") as fh:
44
- _ = fh.write(proposed)
45
- return False
@@ -1,6 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pre_commit_hooks.run_dockfmt import main
4
-
5
- if __name__ == "__main__":
6
- raise SystemExit(int(not main()))
@@ -1,58 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pathlib import Path
4
- from subprocess import PIPE, STDOUT, CalledProcessError, check_call
5
- from typing import Any, cast
6
-
7
- from click import command
8
- from loguru import logger
9
- from tomlkit.container import Container
10
-
11
- from pre_commit_hooks.common import check_versions, read_pyproject
12
-
13
-
14
- @command()
15
- def main() -> bool:
16
- """CLI for the `run-hatch-version` hook."""
17
- return _process()
18
-
19
-
20
- def _process() -> bool:
21
- path = _get_path_version_file()
22
- pattern = r'^__version__ = "(\d+\.\d+\.\d+)"$'
23
- version = check_versions(path, pattern, "run-hatch-version")
24
- if version is None:
25
- return True
26
- cmd = ["hatch", "version", str(version)]
27
- try:
28
- _ = check_call(cmd, stdout=PIPE, stderr=STDOUT)
29
- except CalledProcessError as error:
30
- if error.returncode != 1:
31
- logger.exception("Failed to run {cmd!r}", cmd=" ".join(cmd))
32
- except FileNotFoundError:
33
- logger.exception(
34
- "Failed to run {cmd!r}. Is `hatch` installed?", cmd=" ".join(cmd)
35
- )
36
- else:
37
- return True
38
- return False
39
-
40
-
41
- def _get_path_version_file() -> Path:
42
- pyproject = read_pyproject()
43
- try:
44
- tool = cast(Container, pyproject.doc["tool"])
45
- except KeyError:
46
- logger.exception('pyproject.toml has no "tool" section')
47
- raise
48
- try:
49
- hatch = cast(Container, tool["hatch"])
50
- except KeyError:
51
- logger.exception('pyproject.toml has no "tool.hatch" section')
52
- raise
53
- try:
54
- version = cast(Container, hatch["version"])
55
- except KeyError:
56
- logger.exception('pyproject.toml has no "tool.hatch.version" section')
57
- raise
58
- return Path(cast(Any, version["path"]))
@@ -1,6 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pre_commit_hooks.run_hatch_version import main
4
-
5
- if __name__ == "__main__":
6
- raise SystemExit(int(not main()))
@@ -1,121 +0,0 @@
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,6 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pre_commit_hooks.run_uv_pip_compile import main
4
-
5
- if __name__ == "__main__":
6
- raise SystemExit(int(not main()))
@@ -1,28 +0,0 @@
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