pre-commit-uv 4.1.1__tar.gz → 4.1.3__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.
- {pre_commit_uv-4.1.1 → pre_commit_uv-4.1.3}/PKG-INFO +7 -7
- {pre_commit_uv-4.1.1 → pre_commit_uv-4.1.3}/README.md +1 -1
- {pre_commit_uv-4.1.1 → pre_commit_uv-4.1.3}/pyproject.toml +1 -1
- {pre_commit_uv-4.1.1 → pre_commit_uv-4.1.3}/src/pre_commit_uv/__init__.py +5 -1
- pre_commit_uv-4.1.3/tests/test_main.py +68 -0
- {pre_commit_uv-4.1.1 → pre_commit_uv-4.1.3}/tox.ini +17 -25
- pre_commit_uv-4.1.1/tests/test_main.py +0 -40
- {pre_commit_uv-4.1.1 → pre_commit_uv-4.1.3}/.gitignore +0 -0
- {pre_commit_uv-4.1.1 → pre_commit_uv-4.1.3}/LICENSE.txt +0 -0
- {pre_commit_uv-4.1.1 → pre_commit_uv-4.1.3}/src/pre_commit_uv/py.typed +0 -0
- {pre_commit_uv-4.1.1 → pre_commit_uv-4.1.3}/src/pre_commit_uv_patch.pth +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pre-commit-uv
|
|
3
|
-
Version: 4.1.
|
|
3
|
+
Version: 4.1.3
|
|
4
4
|
Summary: Run pre-commit with uv
|
|
5
5
|
Project-URL: Bug Tracker, https://github.com/tox-dev/pre-commit-uv/issues
|
|
6
6
|
Project-URL: Changelog, https://github.com/tox-dev/pre-commit-uv/releases
|
|
@@ -39,11 +39,11 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
39
39
|
Requires-Python: >=3.9
|
|
40
40
|
Requires-Dist: pre-commit>=3.8
|
|
41
41
|
Requires-Dist: uv>=0.4.7
|
|
42
|
-
Provides-Extra:
|
|
43
|
-
Requires-Dist: covdefaults>=2.3; extra == '
|
|
44
|
-
Requires-Dist: pytest-cov>=5; extra == '
|
|
45
|
-
Requires-Dist: pytest-mock>=3.14; extra == '
|
|
46
|
-
Requires-Dist: pytest>=8.3.2; extra == '
|
|
42
|
+
Provides-Extra: testing
|
|
43
|
+
Requires-Dist: covdefaults>=2.3; extra == 'testing'
|
|
44
|
+
Requires-Dist: pytest-cov>=5; extra == 'testing'
|
|
45
|
+
Requires-Dist: pytest-mock>=3.14; extra == 'testing'
|
|
46
|
+
Requires-Dist: pytest>=8.3.2; extra == 'testing'
|
|
47
47
|
Description-Content-Type: text/markdown
|
|
48
48
|
|
|
49
49
|
# pre-commit-uv
|
|
@@ -53,7 +53,7 @@ Description-Content-Type: text/markdown
|
|
|
53
53
|
[](https://pypi.org/project/pre-commit-uv)
|
|
54
54
|
[](https://pepy.tech/project/pre-commit-uv)
|
|
55
55
|
[](https://opensource.org/licenses/MIT)
|
|
56
|
-
[](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yaml)
|
|
57
57
|
|
|
58
58
|
Use `uv` to create virtual environments and install packages for `pre-commit`.
|
|
59
59
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://pypi.org/project/pre-commit-uv)
|
|
6
6
|
[](https://pepy.tech/project/pre-commit-uv)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
|
-
[](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yaml)
|
|
9
9
|
|
|
10
10
|
Use `uv` to create virtual environments and install packages for `pre-commit`.
|
|
11
11
|
|
|
@@ -16,7 +16,11 @@ def _patch() -> None:
|
|
|
16
16
|
calling_pre_commit = "FORCE_PRE_COMMIT_UV_PATCH" in os.environ
|
|
17
17
|
if not calling_pre_commit and sys.argv and sys.argv[0]: # must have arguments
|
|
18
18
|
calling = sys.argv[1] if sys.argv[0] == sys.executable and len(sys.argv) >= 1 else sys.argv[0]
|
|
19
|
-
if
|
|
19
|
+
if (
|
|
20
|
+
os.path.split(calling)[1] == f"pre-commit{'.exe' if sys.platform == 'win32' else ''}"
|
|
21
|
+
# case when pre-commit is called due to a git commit
|
|
22
|
+
or ("-m" in sys.argv and "hook-impl" in sys.argv)
|
|
23
|
+
):
|
|
20
24
|
calling_pre_commit = True
|
|
21
25
|
|
|
22
26
|
if calling_pre_commit and os.environ.get("DISABLE_PRE_COMMIT_UV_PATCH") is None:
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import version
|
|
4
|
+
from subprocess import check_call, check_output
|
|
5
|
+
from textwrap import dedent
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
from pre_commit import main
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
precommit_file = ".pre-commit-config.yaml"
|
|
15
|
+
uv = version("uv")
|
|
16
|
+
self = version("pre-commit-uv")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.fixture
|
|
20
|
+
def git_repo(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
|
21
|
+
conf = """
|
|
22
|
+
repos:
|
|
23
|
+
- repo: https://github.com/tox-dev/pyproject-fmt
|
|
24
|
+
rev: "2.2.0"
|
|
25
|
+
hooks:
|
|
26
|
+
- id: pyproject-fmt
|
|
27
|
+
"""
|
|
28
|
+
conf_file = tmp_path / precommit_file
|
|
29
|
+
conf_file.write_text(dedent(conf))
|
|
30
|
+
monkeypatch.setenv("PRE_COMMIT_HOME", str(tmp_path / "store"))
|
|
31
|
+
monkeypatch.chdir(tmp_path)
|
|
32
|
+
check_call(["git", "init"])
|
|
33
|
+
return tmp_path
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@pytest.fixture
|
|
37
|
+
def install_hook(git_repo: Path) -> None:
|
|
38
|
+
check_call(["pre-commit", "install", "--install-hooks", "-c", str(git_repo / precommit_file)])
|
|
39
|
+
check_call(["pre-commit", "clean"]) # ensures that 'install_environment' gets called
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@pytest.mark.usefixtures("install_hook")
|
|
43
|
+
def test_run_precommit_hook() -> None:
|
|
44
|
+
hook_result = check_output([".git/hooks/pre-commit"], encoding="utf-8")
|
|
45
|
+
assert f"[INFO] Using pre-commit with uv {uv} via pre-commit-uv {self}" in hook_result.splitlines()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@pytest.mark.usefixtures("install_hook")
|
|
49
|
+
def test_call_as_module() -> None:
|
|
50
|
+
run_result = check_output(["python3", "-m", "pre_commit", "run", "-a", "--color", "never"], encoding="utf-8")
|
|
51
|
+
assert f"[INFO] Using pre-commit with uv {uv} via pre-commit-uv {self}" not in run_result.splitlines()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_install(git_repo: Path, caplog: pytest.LogCaptureFixture, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
55
|
+
monkeypatch.setenv("FORCE_PRE_COMMIT_UV_PATCH", "1")
|
|
56
|
+
|
|
57
|
+
import pre_commit_uv # noqa: PLC0415
|
|
58
|
+
|
|
59
|
+
pre_commit_uv._patch() # noqa: SLF001
|
|
60
|
+
main.main(["install-hooks", "-c", str(git_repo / precommit_file)])
|
|
61
|
+
|
|
62
|
+
assert caplog.messages == [
|
|
63
|
+
"Initializing environment for https://github.com/tox-dev/pyproject-fmt.",
|
|
64
|
+
"Installing environment for https://github.com/tox-dev/pyproject-fmt.",
|
|
65
|
+
"Once installed this environment will be reused.",
|
|
66
|
+
"This may take a few minutes...",
|
|
67
|
+
f"Using pre-commit with uv {uv} via pre-commit-uv {self}",
|
|
68
|
+
]
|
|
@@ -4,73 +4,65 @@ requires =
|
|
|
4
4
|
tox-uv>=1.11.3
|
|
5
5
|
env_list =
|
|
6
6
|
fix
|
|
7
|
-
type
|
|
8
|
-
readme
|
|
9
7
|
3.13
|
|
10
8
|
3.12
|
|
11
9
|
3.11
|
|
12
10
|
3.10
|
|
13
11
|
3.9
|
|
12
|
+
3.8
|
|
13
|
+
type
|
|
14
|
+
pkg_meta
|
|
14
15
|
skip_missing_interpreters = true
|
|
15
16
|
|
|
16
17
|
[testenv]
|
|
17
|
-
description = run the unit tests with pytest under {
|
|
18
|
+
description = run the unit tests with pytest under {base_python}
|
|
18
19
|
package = wheel
|
|
19
20
|
wheel_build_env = .pkg
|
|
20
21
|
extras =
|
|
21
|
-
|
|
22
|
+
testing
|
|
22
23
|
pass_env =
|
|
23
|
-
|
|
24
|
+
PYTEST_*
|
|
24
25
|
set_env =
|
|
25
|
-
COVERAGE_FILE = {
|
|
26
|
-
FORCE_PRE_COMMIT_UV_PATCH = true
|
|
26
|
+
COVERAGE_FILE = {work_dir}/.coverage.{env_name}
|
|
27
27
|
commands =
|
|
28
28
|
python -m pytest {tty:--color=yes} {posargs: \
|
|
29
|
-
--
|
|
30
|
-
--cov {toxinidir}{/}tests \
|
|
29
|
+
--cov {env_site_packages_dir}{/}pre_commit_uv --cov {tox_root}{/}tests \
|
|
31
30
|
--cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \
|
|
32
|
-
--cov-report html:{
|
|
31
|
+
--cov-report html:{env_tmp_dir}{/}htmlcov --cov-report xml:{work_dir}{/}coverage.{env_name}.xml \
|
|
32
|
+
--junitxml {work_dir}{/}junit.{env_name}.xml \
|
|
33
33
|
tests}
|
|
34
34
|
|
|
35
35
|
[testenv:fix]
|
|
36
|
-
description =
|
|
36
|
+
description = format the code base to adhere to our styles, and complain about what we cannot do automatically
|
|
37
37
|
skip_install = true
|
|
38
38
|
deps =
|
|
39
|
-
pre-commit-uv>=4.1
|
|
39
|
+
pre-commit-uv>=4.1.1
|
|
40
40
|
commands =
|
|
41
41
|
pre-commit run --all-files --show-diff-on-failure
|
|
42
|
-
python -c 'print("hint: run {envdir}/bin/pre-commit install to add checks as pre-commit hook")'
|
|
43
42
|
|
|
44
43
|
[testenv:type]
|
|
45
44
|
description = run type check on code base
|
|
46
45
|
deps =
|
|
47
46
|
mypy==1.11.2
|
|
48
|
-
set_env =
|
|
49
|
-
{tty:MYPY_FORCE_COLOR = 1}
|
|
50
47
|
commands =
|
|
51
48
|
mypy src
|
|
52
49
|
mypy tests
|
|
53
50
|
|
|
54
|
-
[testenv:
|
|
51
|
+
[testenv:pkg_meta]
|
|
55
52
|
description = check that the long description is valid
|
|
56
53
|
skip_install = true
|
|
57
54
|
deps =
|
|
58
|
-
build[uv]>=1.2.2
|
|
59
55
|
check-wheel-contents>=0.6
|
|
60
56
|
twine>=5.1.1
|
|
57
|
+
uv>=0.4.10
|
|
61
58
|
commands =
|
|
62
|
-
|
|
63
|
-
twine check {
|
|
64
|
-
check-wheel-contents --no-config {
|
|
59
|
+
uv build --sdist --wheel --out-dir {env_tmp_dir} .
|
|
60
|
+
twine check {env_tmp_dir}{/}*
|
|
61
|
+
check-wheel-contents --no-config {env_tmp_dir}
|
|
65
62
|
|
|
66
63
|
[testenv:dev]
|
|
67
64
|
description = generate a DEV environment
|
|
68
65
|
package = editable
|
|
69
|
-
extras =
|
|
70
|
-
docs
|
|
71
|
-
test
|
|
72
|
-
set_env =
|
|
73
|
-
FORCE_PRE_COMMIT_UV_PATCH = true
|
|
74
66
|
commands =
|
|
75
67
|
uv tree
|
|
76
68
|
python -c 'import sys; print(sys.executable)'
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from importlib.metadata import version
|
|
4
|
-
from subprocess import check_call
|
|
5
|
-
from textwrap import dedent
|
|
6
|
-
from typing import TYPE_CHECKING
|
|
7
|
-
|
|
8
|
-
from pre_commit import main
|
|
9
|
-
|
|
10
|
-
if TYPE_CHECKING:
|
|
11
|
-
from pathlib import Path
|
|
12
|
-
|
|
13
|
-
import pytest
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_install(tmp_path: Path, caplog: pytest.LogCaptureFixture, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
17
|
-
conf = """
|
|
18
|
-
repos:
|
|
19
|
-
- repo: https://github.com/tox-dev/pyproject-fmt
|
|
20
|
-
rev: "2.2.0"
|
|
21
|
-
hooks:
|
|
22
|
-
- id: pyproject-fmt
|
|
23
|
-
"""
|
|
24
|
-
conf_file = tmp_path / ".pre-commit-config.yaml"
|
|
25
|
-
conf_file.write_text(dedent(conf))
|
|
26
|
-
monkeypatch.setenv("PRE_COMMIT_HOME", str(tmp_path / "store"))
|
|
27
|
-
monkeypatch.chdir(tmp_path)
|
|
28
|
-
check_call(["git", "init"])
|
|
29
|
-
|
|
30
|
-
main.main(["install-hooks", "-c", str(conf_file)])
|
|
31
|
-
|
|
32
|
-
uv = version("uv")
|
|
33
|
-
self = version("pre-commit-uv")
|
|
34
|
-
assert caplog.messages == [
|
|
35
|
-
"Initializing environment for https://github.com/tox-dev/pyproject-fmt.",
|
|
36
|
-
"Installing environment for https://github.com/tox-dev/pyproject-fmt.",
|
|
37
|
-
"Once installed this environment will be reused.",
|
|
38
|
-
"This may take a few minutes...",
|
|
39
|
-
f"Using pre-commit with uv {uv} via pre-commit-uv {self}",
|
|
40
|
-
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|