pre-commit-uv 3.8.0__tar.gz → 4.0.1__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.
Files changed (102) hide show
  1. pre_commit_uv-4.0.1/.gitignore +6 -0
  2. pre_commit_uv-4.0.1/LICENSE.txt +18 -0
  3. pre_commit_uv-4.0.1/PKG-INFO +88 -0
  4. pre_commit_uv-4.0.1/README.md +41 -0
  5. pre_commit_uv-4.0.1/pyproject.toml +134 -0
  6. pre_commit_uv-4.0.1/src/pre_commit_uv/__init__.py +93 -0
  7. pre_commit_uv-4.0.1/src/pre_commit_uv_patch.pth +1 -0
  8. pre_commit_uv-4.0.1/tests/test_main.py +40 -0
  9. pre_commit_uv-4.0.1/tox.ini +75 -0
  10. pre_commit_uv-3.8.0/LICENSE +0 -19
  11. pre_commit_uv-3.8.0/PKG-INFO +0 -30
  12. pre_commit_uv-3.8.0/README.md +0 -7
  13. pre_commit_uv-3.8.0/pre_commit/__main__.py +0 -7
  14. pre_commit_uv-3.8.0/pre_commit/all_languages.py +0 -50
  15. pre_commit_uv-3.8.0/pre_commit/clientlib.py +0 -405
  16. pre_commit_uv-3.8.0/pre_commit/color.py +0 -109
  17. pre_commit_uv-3.8.0/pre_commit/commands/__init__.py +0 -0
  18. pre_commit_uv-3.8.0/pre_commit/commands/autoupdate.py +0 -215
  19. pre_commit_uv-3.8.0/pre_commit/commands/clean.py +0 -16
  20. pre_commit_uv-3.8.0/pre_commit/commands/gc.py +0 -89
  21. pre_commit_uv-3.8.0/pre_commit/commands/hook_impl.py +0 -271
  22. pre_commit_uv-3.8.0/pre_commit/commands/init_templatedir.py +0 -39
  23. pre_commit_uv-3.8.0/pre_commit/commands/install_uninstall.py +0 -167
  24. pre_commit_uv-3.8.0/pre_commit/commands/migrate_config.py +0 -75
  25. pre_commit_uv-3.8.0/pre_commit/commands/run.py +0 -447
  26. pre_commit_uv-3.8.0/pre_commit/commands/sample_config.py +0 -18
  27. pre_commit_uv-3.8.0/pre_commit/commands/try_repo.py +0 -77
  28. pre_commit_uv-3.8.0/pre_commit/commands/validate_config.py +0 -18
  29. pre_commit_uv-3.8.0/pre_commit/commands/validate_manifest.py +0 -18
  30. pre_commit_uv-3.8.0/pre_commit/constants.py +0 -13
  31. pre_commit_uv-3.8.0/pre_commit/envcontext.py +0 -62
  32. pre_commit_uv-3.8.0/pre_commit/error_handler.py +0 -81
  33. pre_commit_uv-3.8.0/pre_commit/errors.py +0 -5
  34. pre_commit_uv-3.8.0/pre_commit/file_lock.py +0 -75
  35. pre_commit_uv-3.8.0/pre_commit/git.py +0 -245
  36. pre_commit_uv-3.8.0/pre_commit/hook.py +0 -60
  37. pre_commit_uv-3.8.0/pre_commit/lang_base.py +0 -192
  38. pre_commit_uv-3.8.0/pre_commit/languages/__init__.py +0 -0
  39. pre_commit_uv-3.8.0/pre_commit/languages/conda.py +0 -77
  40. pre_commit_uv-3.8.0/pre_commit/languages/coursier.py +0 -76
  41. pre_commit_uv-3.8.0/pre_commit/languages/dart.py +0 -97
  42. pre_commit_uv-3.8.0/pre_commit/languages/docker.py +0 -151
  43. pre_commit_uv-3.8.0/pre_commit/languages/docker_image.py +0 -32
  44. pre_commit_uv-3.8.0/pre_commit/languages/dotnet.py +0 -111
  45. pre_commit_uv-3.8.0/pre_commit/languages/fail.py +0 -27
  46. pre_commit_uv-3.8.0/pre_commit/languages/golang.py +0 -160
  47. pre_commit_uv-3.8.0/pre_commit/languages/haskell.py +0 -56
  48. pre_commit_uv-3.8.0/pre_commit/languages/lua.py +0 -75
  49. pre_commit_uv-3.8.0/pre_commit/languages/node.py +0 -110
  50. pre_commit_uv-3.8.0/pre_commit/languages/perl.py +0 -50
  51. pre_commit_uv-3.8.0/pre_commit/languages/pygrep.py +0 -133
  52. pre_commit_uv-3.8.0/pre_commit/languages/python.py +0 -295
  53. pre_commit_uv-3.8.0/pre_commit/languages/r.py +0 -254
  54. pre_commit_uv-3.8.0/pre_commit/languages/ruby.py +0 -145
  55. pre_commit_uv-3.8.0/pre_commit/languages/rust.py +0 -160
  56. pre_commit_uv-3.8.0/pre_commit/languages/script.py +0 -32
  57. pre_commit_uv-3.8.0/pre_commit/languages/swift.py +0 -50
  58. pre_commit_uv-3.8.0/pre_commit/languages/system.py +0 -10
  59. pre_commit_uv-3.8.0/pre_commit/logging_handler.py +0 -42
  60. pre_commit_uv-3.8.0/pre_commit/main.py +0 -442
  61. pre_commit_uv-3.8.0/pre_commit/meta_hooks/__init__.py +0 -0
  62. pre_commit_uv-3.8.0/pre_commit/meta_hooks/check_hooks_apply.py +0 -43
  63. pre_commit_uv-3.8.0/pre_commit/meta_hooks/check_useless_excludes.py +0 -83
  64. pre_commit_uv-3.8.0/pre_commit/meta_hooks/identity.py +0 -17
  65. pre_commit_uv-3.8.0/pre_commit/output.py +0 -33
  66. pre_commit_uv-3.8.0/pre_commit/parse_shebang.py +0 -85
  67. pre_commit_uv-3.8.0/pre_commit/prefix.py +0 -18
  68. pre_commit_uv-3.8.0/pre_commit/repository.py +0 -246
  69. pre_commit_uv-3.8.0/pre_commit/resources/__init__.py +0 -0
  70. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_.npmignore +0 -1
  71. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_Cargo.toml +0 -7
  72. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_LICENSE.renv +0 -7
  73. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_Makefile.PL +0 -6
  74. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_activate.R +0 -440
  75. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_environment.yml +0 -9
  76. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_go.mod +0 -1
  77. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_main.go +0 -3
  78. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_main.rs +0 -1
  79. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_package.json +0 -4
  80. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_pre-commit-package-dev-1.rockspec +0 -12
  81. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_pre_commit_placeholder_package.gemspec +0 -6
  82. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_pubspec.yaml +0 -4
  83. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_renv.lock +0 -20
  84. pre_commit_uv-3.8.0/pre_commit/resources/empty_template_setup.py +0 -4
  85. pre_commit_uv-3.8.0/pre_commit/resources/hook-tmpl +0 -20
  86. pre_commit_uv-3.8.0/pre_commit/resources/rbenv.tar.gz +0 -0
  87. pre_commit_uv-3.8.0/pre_commit/resources/ruby-build.tar.gz +0 -0
  88. pre_commit_uv-3.8.0/pre_commit/resources/ruby-download.tar.gz +0 -0
  89. pre_commit_uv-3.8.0/pre_commit/staged_files_only.py +0 -113
  90. pre_commit_uv-3.8.0/pre_commit/store.py +0 -254
  91. pre_commit_uv-3.8.0/pre_commit/util.py +0 -239
  92. pre_commit_uv-3.8.0/pre_commit/xargs.py +0 -185
  93. pre_commit_uv-3.8.0/pre_commit/yaml.py +0 -18
  94. pre_commit_uv-3.8.0/pre_commit_uv.egg-info/PKG-INFO +0 -30
  95. pre_commit_uv-3.8.0/pre_commit_uv.egg-info/SOURCES.txt +0 -92
  96. pre_commit_uv-3.8.0/pre_commit_uv.egg-info/dependency_links.txt +0 -1
  97. pre_commit_uv-3.8.0/pre_commit_uv.egg-info/entry_points.txt +0 -2
  98. pre_commit_uv-3.8.0/pre_commit_uv.egg-info/requires.txt +0 -6
  99. pre_commit_uv-3.8.0/pre_commit_uv.egg-info/top_level.txt +0 -1
  100. pre_commit_uv-3.8.0/setup.cfg +0 -69
  101. pre_commit_uv-3.8.0/setup.py +0 -4
  102. /pre_commit_uv-3.8.0/pre_commit/__init__.py → /pre_commit_uv-4.0.1/src/pre_commit_uv/py.typed +0 -0
@@ -0,0 +1,6 @@
1
+ *.egg-info/
2
+ .tox/
3
+ .*_cache
4
+ __pycache__
5
+ **.pyc
6
+ dist
@@ -0,0 +1,18 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining a
2
+ copy of this software and associated documentation files (the
3
+ "Software"), to deal in the Software without restriction, including
4
+ without limitation the rights to use, copy, modify, merge, publish,
5
+ distribute, sublicense, and/or sell copies of the Software, and to
6
+ permit persons to whom the Software is furnished to do so, subject to
7
+ the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included
10
+ in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
15
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
16
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
17
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.3
2
+ Name: pre-commit-uv
3
+ Version: 4.0.1
4
+ Summary: Run pre-commit with uv
5
+ Project-URL: Bug Tracker, https://github.com/tox-dev/pre-commit-uv/issues
6
+ Project-URL: Changelog, https://github.com/tox-dev/pre-commit-uv/releases
7
+ Project-URL: Documentation, https://github.com/tox-dev/pre-commit-uv/
8
+ Project-URL: Source Code, https://github.com/tox-dev/pre-commit-uv
9
+ Author-email: Bernat Gabor <gaborjbernat@gmail.com>
10
+ License: Permission is hereby granted, free of charge, to any person obtaining a
11
+ copy of this software and associated documentation files (the
12
+ "Software"), to deal in the Software without restriction, including
13
+ without limitation the rights to use, copy, modify, merge, publish,
14
+ distribute, sublicense, and/or sell copies of the Software, and to
15
+ permit persons to whom the Software is furnished to do so, subject to
16
+ the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included
19
+ in all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ License-File: LICENSE.txt
29
+ Keywords: format,pyproject
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Operating System :: OS Independent
32
+ Classifier: Programming Language :: Python
33
+ Classifier: Programming Language :: Python :: 3 :: Only
34
+ Classifier: Programming Language :: Python :: 3.9
35
+ Classifier: Programming Language :: Python :: 3.10
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Requires-Python: >=3.9
39
+ Requires-Dist: pre-commit>=3.8
40
+ Requires-Dist: uv>=0.2.33
41
+ Provides-Extra: test
42
+ Requires-Dist: covdefaults>=2.3; extra == 'test'
43
+ Requires-Dist: pytest-cov>=5; extra == 'test'
44
+ Requires-Dist: pytest-mock>=3.14; extra == 'test'
45
+ Requires-Dist: pytest>=8.3.2; extra == 'test'
46
+ Description-Content-Type: text/markdown
47
+
48
+ # pre-commit-uv
49
+
50
+ [![PyPI](https://img.shields.io/pypi/v/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
51
+ [![PyPI - Implementation](https://img.shields.io/pypi/implementation/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
52
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
53
+ [![Downloads](https://static.pepy.tech/badge/pre-commit-uv/month)](https://pepy.tech/project/pre-commit-uv)
54
+ [![PyPI - License](https://img.shields.io/pypi/l/pre-commit-uv?style=flat-square)](https://opensource.org/licenses/MIT)
55
+ [![check](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yml/badge.svg)](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yml)
56
+
57
+ Use `uv` to create virtual environments and install packages for `pre-commit`.
58
+
59
+ ## Why?
60
+
61
+ Compared to upstream `pre-commit` will speed up the initial seed operation. In general, upstream recommends caching the
62
+ `pre-commit` cache, however, that is not always possible and is still helpful to have a more performant initial cache
63
+ creation., Here's an example of what you could expect demonstrated on this project's own pre-commit setup (with a hot
64
+ `uv` cache):
65
+
66
+ ```shell
67
+ ❯ hyperfine 'pre-commit install-hooks' 'pre-commit-uv install-hooks'
68
+ Benchmark 1: pre-commit install-hooks
69
+ Time (mean ± σ): 54.132 s ± 8.827 s [User: 15.424 s, System: 9.359 s]
70
+ Range (min … max): 45.972 s … 66.506 s 10 runs
71
+
72
+ Benchmark 2: pre-commit-uv install-hooks
73
+ Time (mean ± σ): 41.695 s ± 7.395 s [User: 7.614 s, System: 6.133 s]
74
+ Range (min … max): 32.198 s … 58.467 s 10 runs
75
+
76
+ Summary
77
+ pre-commit-uv install-hooks ran 1.30 ± 0.31 times faster than pre-commit install-hooks
78
+ ```
79
+
80
+ ## Configuration
81
+
82
+ Once installed will use `uv` out of box, however the `DISABLE_PRE_COMMIT_UV_PATCH` environment variable if is set it
83
+ will work as an escape hatch to disable the new behavior.
84
+
85
+ To avoid interpreter startup overhead of the patching, we only perform this when we detect you calling `pre-commit`.
86
+ Should this logic fail you can force the patching by setting the `FORCE_PRE_COMMIT_UV_PATCH` variable. Should you
87
+ experience this please raise an issue with the content of the `sys.argv`. Note that `DISABLE_PRE_COMMIT_UV_PATCH` will
88
+ overwrite this flag should both be set.
@@ -0,0 +1,41 @@
1
+ # pre-commit-uv
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
4
+ [![PyPI - Implementation](https://img.shields.io/pypi/implementation/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
5
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
6
+ [![Downloads](https://static.pepy.tech/badge/pre-commit-uv/month)](https://pepy.tech/project/pre-commit-uv)
7
+ [![PyPI - License](https://img.shields.io/pypi/l/pre-commit-uv?style=flat-square)](https://opensource.org/licenses/MIT)
8
+ [![check](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yml/badge.svg)](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yml)
9
+
10
+ Use `uv` to create virtual environments and install packages for `pre-commit`.
11
+
12
+ ## Why?
13
+
14
+ Compared to upstream `pre-commit` will speed up the initial seed operation. In general, upstream recommends caching the
15
+ `pre-commit` cache, however, that is not always possible and is still helpful to have a more performant initial cache
16
+ creation., Here's an example of what you could expect demonstrated on this project's own pre-commit setup (with a hot
17
+ `uv` cache):
18
+
19
+ ```shell
20
+ ❯ hyperfine 'pre-commit install-hooks' 'pre-commit-uv install-hooks'
21
+ Benchmark 1: pre-commit install-hooks
22
+ Time (mean ± σ): 54.132 s ± 8.827 s [User: 15.424 s, System: 9.359 s]
23
+ Range (min … max): 45.972 s … 66.506 s 10 runs
24
+
25
+ Benchmark 2: pre-commit-uv install-hooks
26
+ Time (mean ± σ): 41.695 s ± 7.395 s [User: 7.614 s, System: 6.133 s]
27
+ Range (min … max): 32.198 s … 58.467 s 10 runs
28
+
29
+ Summary
30
+ pre-commit-uv install-hooks ran 1.30 ± 0.31 times faster than pre-commit install-hooks
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ Once installed will use `uv` out of box, however the `DISABLE_PRE_COMMIT_UV_PATCH` environment variable if is set it
36
+ will work as an escape hatch to disable the new behavior.
37
+
38
+ To avoid interpreter startup overhead of the patching, we only perform this when we detect you calling `pre-commit`.
39
+ Should this logic fail you can force the patching by setting the `FORCE_PRE_COMMIT_UV_PATCH` variable. Should you
40
+ experience this please raise an issue with the content of the `sys.argv`. Note that `DISABLE_PRE_COMMIT_UV_PATCH` will
41
+ overwrite this flag should both be set.
@@ -0,0 +1,134 @@
1
+ [build-system]
2
+ build-backend = "hatchling.build"
3
+ requires = [
4
+ "hatch-vcs>=0.4",
5
+ "hatchling>=1.25",
6
+ ]
7
+
8
+ [project]
9
+ name = "pre-commit-uv"
10
+ description = "Run pre-commit with uv"
11
+ readme = "README.md"
12
+ keywords = [
13
+ "format",
14
+ "pyproject",
15
+ ]
16
+ license.file = "LICENSE.txt"
17
+ authors = [
18
+ { name = "Bernat Gabor", email = "gaborjbernat@gmail.com" },
19
+ ]
20
+ requires-python = ">=3.9"
21
+ classifiers = [
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ "Programming Language :: Python",
25
+ "Programming Language :: Python :: 3 :: Only",
26
+ "Programming Language :: Python :: 3.9",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ ]
31
+ dynamic = [
32
+ "version",
33
+ ]
34
+ dependencies = [
35
+ "pre-commit>=3.8",
36
+ "uv>=0.2.33",
37
+ ]
38
+ optional-dependencies.test = [
39
+ "covdefaults>=2.3",
40
+ "pytest>=8.3.2",
41
+ "pytest-cov>=5",
42
+ "pytest-mock>=3.14",
43
+ ]
44
+ urls."Bug Tracker" = "https://github.com/tox-dev/pre-commit-uv/issues"
45
+ urls."Changelog" = "https://github.com/tox-dev/pre-commit-uv/releases"
46
+ urls.Documentation = "https://github.com/tox-dev/pre-commit-uv/"
47
+ urls."Source Code" = "https://github.com/tox-dev/pre-commit-uv"
48
+
49
+ [tool.hatch]
50
+ build.dev-mode-dirs = [
51
+ "src",
52
+ ]
53
+ build.targets.sdist.include = [
54
+ "/src",
55
+ "/tests",
56
+ "tox.ini",
57
+ ]
58
+ build.targets.wheel.only-include = [ "src" ]
59
+ build.targets.wheel.sources = [ "src" ]
60
+ version.source = "vcs"
61
+
62
+ [tool.ruff]
63
+ target-version = "py39"
64
+ line-length = 120
65
+ format.preview = true
66
+ format.docstring-code-line-length = 100
67
+ format.docstring-code-format = true
68
+ lint.select = [
69
+ "ALL",
70
+ ]
71
+ lint.ignore = [
72
+ "ANN101", # no type annotation for self
73
+ "ANN401", # allow Any as type annotation
74
+ "COM812", # Conflict with formatter
75
+ "CPY", # No copyright statements
76
+ "D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
77
+ "D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
78
+ "DOC501", # not working with Sphinx
79
+ "ISC001", # Conflict with formatter
80
+ "S104", # Possible binding to all interfaces
81
+ ]
82
+ lint.per-file-ignores."tests/**/*.py" = [
83
+ "D", # don"t care about documentation in tests
84
+ "FBT", # don"t care about booleans as positional arguments in tests
85
+ "INP001", # no implicit namespace
86
+ "PLC2701", # private import
87
+ "PLR0913", # any number of arguments in tests
88
+ "PLR0917", # any number of arguments in tests
89
+ "PLR2004", # Magic value used in comparison, consider replacing with a constant variable
90
+ "S", # `subprocess` call: check for execution of untrusted input
91
+ "S101", # asserts allowed in tests...
92
+ ]
93
+ lint.isort = { known-first-party = [
94
+ "pre_commit_uv",
95
+ ], required-imports = [
96
+ "from __future__ import annotations",
97
+ ] }
98
+ lint.preview = true
99
+
100
+ [tool.codespell]
101
+ builtin = "clear,usage,en-GB_to_en-US"
102
+ count = true
103
+
104
+ [tool.pytest]
105
+ ini_options.testpaths = [
106
+ "tests",
107
+ ]
108
+
109
+ [tool.coverage]
110
+ html.show_contexts = true
111
+ html.skip_covered = false
112
+ paths.source = [
113
+ "src",
114
+ ".tox/*/.venv/lib/*/site-packages",
115
+ ".tox\\*\\.venv\\Lib\\site-packages",
116
+ ".tox/*/lib/*/site-packages",
117
+ ".tox\\*\\Lib\\site-packages",
118
+ "**/src",
119
+ "**\\src",
120
+ ]
121
+ report.fail_under = 65
122
+ run.parallel = true
123
+ run.plugins = [
124
+ "covdefaults",
125
+ ]
126
+
127
+ [tool.mypy]
128
+ show_error_codes = true
129
+ strict = true
130
+ overrides = [
131
+ { module = [
132
+ "pre_commit.*",
133
+ ], ignore_missing_imports = true },
134
+ ]
@@ -0,0 +1,93 @@
1
+ """Package root."""
2
+
3
+ from __future__ import annotations
4
+
5
+ # only import built-ins at top level to avoid interpreter startup overhead
6
+ import os
7
+ import sys
8
+
9
+ _original_main = None
10
+
11
+
12
+ def _patch() -> None:
13
+ global _original_main
14
+ if _original_main is not None: # already patched, nothing more to do
15
+ return
16
+ calling_pre_commit = "FORCE_PRE_COMMIT_UV_PATCH" in os.environ
17
+ if not calling_pre_commit and sys.argv and sys.argv[0]: # must have arguments
18
+ calling = sys.argv[1] if sys.argv[0] == sys.executable and len(sys.argv) >= 1 else sys.argv[0]
19
+ if os.path.split(calling)[1] == f"pre-commit{'.exe' if sys.platform == 'win32' else ''}":
20
+ calling_pre_commit = True
21
+
22
+ if calling_pre_commit and os.environ.get("DISABLE_PRE_COMMIT_UV_PATCH") is None:
23
+ from pre_commit import main # noqa: PLC0415
24
+
25
+ _original_main, main.main = main.main, _new_main
26
+
27
+
28
+ def _new_main(argv: list[str] | None = None) -> int:
29
+ # imports applied locally to avoid patching import overhead cost
30
+ from functools import cache # noqa: PLC0415
31
+ from typing import TYPE_CHECKING, cast # noqa: PLC0415
32
+
33
+ from pre_commit.languages import python # noqa: PLC0415
34
+
35
+ if TYPE_CHECKING:
36
+ from collections.abc import Sequence # noqa: PLC0415
37
+
38
+ from pre_commit.prefix import Prefix # noqa: PLC0415
39
+
40
+ def _install_environment(
41
+ prefix: Prefix,
42
+ version: str,
43
+ additional_dependencies: Sequence[str],
44
+ ) -> None:
45
+ import logging # noqa: PLC0415
46
+
47
+ from pre_commit.lang_base import environment_dir, setup_cmd # noqa: PLC0415
48
+ from pre_commit.util import cmd_output_b # noqa: PLC0415
49
+
50
+ logger = logging.getLogger("pre_commit")
51
+ logger.info("Using pre-commit with uv %s via pre-commit-uv %s", uv_version(), self_version())
52
+ uv = _uv()
53
+ venv_cmd = [uv, "venv", environment_dir(prefix, python.ENVIRONMENT_DIR, version)]
54
+ py = python.norm_version(version)
55
+ if py is not None:
56
+ venv_cmd.extend(("-p", py))
57
+ cmd_output_b(*venv_cmd, cwd="/")
58
+
59
+ with python.in_env(prefix, version):
60
+ setup_cmd(prefix, (uv, "pip", "install", ".", *additional_dependencies))
61
+
62
+ @cache
63
+ def _uv() -> str:
64
+ from uv import find_uv_bin # noqa: PLC0415
65
+
66
+ return find_uv_bin()
67
+
68
+ @cache
69
+ def self_version() -> str:
70
+ from importlib.metadata import version as _metadata_version # noqa: PLC0415
71
+
72
+ return _metadata_version("pre-commit-uv")
73
+
74
+ @cache
75
+ def uv_version() -> str:
76
+ from importlib.metadata import version as _metadata_version # noqa: PLC0415
77
+
78
+ return _metadata_version("uv")
79
+
80
+ @cache
81
+ def _version_info(exe: str) -> str:
82
+ from pre_commit.util import CalledProcessError, cmd_output # noqa: PLC0415
83
+
84
+ prog = 'import sys;print(".".join(str(p) for p in sys.version_info[0:3]))'
85
+ try:
86
+ return cast(str, cmd_output(exe, "-S", "-c", prog)[1].strip())
87
+ except CalledProcessError:
88
+ return f"<<error retrieving version from {exe}>>"
89
+
90
+ python.install_environment = _install_environment
91
+ python._version_info = _version_info # noqa: SLF001
92
+ assert _original_main is not None # noqa: S101
93
+ return cast(int, _original_main(argv))
@@ -0,0 +1 @@
1
+ import pre_commit_uv; pre_commit_uv._patch()
@@ -0,0 +1,40 @@
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
+ ]
@@ -0,0 +1,75 @@
1
+ [tox]
2
+ requires =
3
+ tox>=4.17.1
4
+ env_list =
5
+ fix
6
+ type
7
+ readme
8
+ 3.12
9
+ 3.11
10
+ 3.10
11
+ 3.9
12
+ skip_missing_interpreters = true
13
+
14
+ [testenv]
15
+ description = run the unit tests with pytest under {basepython}
16
+ package = wheel
17
+ wheel_build_env = .pkg
18
+ extras =
19
+ test
20
+ pass_env =
21
+ PYTEST_ADDOPTS
22
+ set_env =
23
+ COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
24
+ FORCE_PRE_COMMIT_UV_PATCH = true
25
+ commands =
26
+ python -m pytest {tty:--color=yes} {posargs: \
27
+ --junitxml {toxworkdir}{/}junit.{envname}.xml --cov {envsitepackagesdir}{/}pre_commit_uv \
28
+ --cov {toxinidir}{/}tests \
29
+ --cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \
30
+ --cov-report html:{envtmpdir}{/}htmlcov --cov-report xml:{toxworkdir}{/}coverage.{envname}.xml \
31
+ tests}
32
+
33
+ [testenv:fix]
34
+ description = run static analysis and style check using flake8
35
+ skip_install = true
36
+ deps =
37
+ pre-commit>=3.8
38
+ commands =
39
+ pre-commit run --all-files --show-diff-on-failure
40
+ python -c 'print("hint: run {envdir}/bin/pre-commit install to add checks as pre-commit hook")'
41
+
42
+ [testenv:type]
43
+ description = run type check on code base
44
+ deps =
45
+ mypy==1.11.1
46
+ set_env =
47
+ {tty:MYPY_FORCE_COLOR = 1}
48
+ commands =
49
+ mypy src
50
+ mypy tests
51
+
52
+ [testenv:readme]
53
+ description = check that the long description is valid
54
+ skip_install = true
55
+ deps =
56
+ build[uv]>=1.2.1
57
+ check-wheel-contents>=0.6
58
+ twine>=5.1.1
59
+ commands =
60
+ python -m build --installer uv --sdist --wheel -o {envtmpdir} .
61
+ twine check {envtmpdir}/*
62
+ check-wheel-contents {envtmpdir}
63
+
64
+ [testenv:dev]
65
+ description = generate a DEV environment
66
+ package = editable
67
+ extras =
68
+ docs
69
+ test
70
+ set_env =
71
+ FORCE_PRE_COMMIT_UV_PATCH = true
72
+ commands =
73
+ uv tree
74
+ python -c 'import sys; print(sys.executable)'
75
+ python task/dev_pth.py {env_site_packages_dir}
@@ -1,19 +0,0 @@
1
- Copyright (c) 2014 pre-commit dev team: Anthony Sottile, Ken Struys
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
@@ -1,30 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pre_commit_uv
3
- Version: 3.8.0
4
- Summary: A framework for managing and maintaining multi-language pre-commit hooks (fork with uv support).
5
- Home-page: https://github.com/pre-commit/pre-commit
6
- Author: "Guilherme Espada, Anthony Sottile"
7
- Author-email: gjespada@fc.ul.pt
8
- License: MIT
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3 :: Only
12
- Classifier: Programming Language :: Python :: Implementation :: CPython
13
- Classifier: Programming Language :: Python :: Implementation :: PyPy
14
- Requires-Python: >=3.9
15
- Description-Content-Type: text/markdown
16
- License-File: LICENSE
17
- Requires-Dist: cfgv>=2.0.0
18
- Requires-Dist: identify>=1.0.0
19
- Requires-Dist: nodeenv>=0.11.1
20
- Requires-Dist: pyyaml>=5.1
21
- Requires-Dist: tomlkit>=0.12.4
22
- Requires-Dist: virtualenv>=20.10.0
23
-
24
- ## pre-commit-uv
25
-
26
- *Note:* This is a minor fork of the upstream pre-commit project. It is published on pypi as `pre-commit-uv`.
27
-
28
- A framework for managing and maintaining multi-language pre-commit hooks.
29
-
30
- For more information see: https://pre-commit.com/
@@ -1,7 +0,0 @@
1
- ## pre-commit-uv
2
-
3
- *Note:* This is a minor fork of the upstream pre-commit project. It is published on pypi as `pre-commit-uv`.
4
-
5
- A framework for managing and maintaining multi-language pre-commit hooks.
6
-
7
- For more information see: https://pre-commit.com/
@@ -1,7 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pre_commit.main import main
4
-
5
-
6
- if __name__ == '__main__':
7
- raise SystemExit(main())
@@ -1,50 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pre_commit.lang_base import Language
4
- from pre_commit.languages import conda
5
- from pre_commit.languages import coursier
6
- from pre_commit.languages import dart
7
- from pre_commit.languages import docker
8
- from pre_commit.languages import docker_image
9
- from pre_commit.languages import dotnet
10
- from pre_commit.languages import fail
11
- from pre_commit.languages import golang
12
- from pre_commit.languages import haskell
13
- from pre_commit.languages import lua
14
- from pre_commit.languages import node
15
- from pre_commit.languages import perl
16
- from pre_commit.languages import pygrep
17
- from pre_commit.languages import python
18
- from pre_commit.languages import r
19
- from pre_commit.languages import ruby
20
- from pre_commit.languages import rust
21
- from pre_commit.languages import script
22
- from pre_commit.languages import swift
23
- from pre_commit.languages import system
24
-
25
-
26
- languages: dict[str, Language] = {
27
- 'conda': conda,
28
- 'coursier': coursier,
29
- 'dart': dart,
30
- 'docker': docker,
31
- 'docker_image': docker_image,
32
- 'dotnet': dotnet,
33
- 'fail': fail,
34
- 'golang': golang,
35
- 'haskell': haskell,
36
- 'lua': lua,
37
- 'node': node,
38
- 'perl': perl,
39
- 'pygrep': pygrep,
40
- 'python': python,
41
- 'r': r,
42
- 'ruby': ruby,
43
- 'rust': rust,
44
- 'script': script,
45
- 'swift': swift,
46
- 'system': system,
47
- # TODO: fully deprecate `python_venv`
48
- 'python_venv': python,
49
- }
50
- language_names = sorted(languages)