pyproject-pre-commit 0.5.2__tar.gz → 0.6.0__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.
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/.pre-commit-config.yaml +30 -34
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/PKG-INFO +99 -60
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/README.md +86 -48
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/pyproject.toml +23 -21
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/src/pyproject_pre_commit/__init__.py +1 -1
- pyproject_pre_commit-0.6.0/src/pyproject_pre_commit/pyproject_pre_commit.py +167 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/tests/test_pyproject_pre_commit.py +11 -11
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/tests/test_version.py +2 -2
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/uv.lock +240 -217
- pyproject_pre_commit-0.5.2/src/pyproject_pre_commit/pyproject_pre_commit.py +0 -168
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/.github/FUNDING.yml +0 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/.github/workflows/pypi.yml +0 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/.github/workflows/test.yml +0 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/.gitignore +0 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/.mise.toml +0 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/.pre-commit-hooks.yaml +0 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/LICENSE +0 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/renovate.json +0 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/src/pyproject_pre_commit/__version__.py +0 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/src/pyproject_pre_commit/py.typed +0 -0
- {pyproject_pre_commit-0.5.2 → pyproject_pre_commit-0.6.0}/tests/__init__.py +0 -0
|
@@ -13,7 +13,6 @@ repos:
|
|
|
13
13
|
- pyi
|
|
14
14
|
- jupyter
|
|
15
15
|
require_serial: true
|
|
16
|
-
minimum_pre_commit_version: "2.9.2"
|
|
17
16
|
verbose: true
|
|
18
17
|
- id: ruff-lint
|
|
19
18
|
# https://github.com/astral-sh/ruff-pre-commit
|
|
@@ -26,7 +25,6 @@ repos:
|
|
|
26
25
|
- pyi
|
|
27
26
|
- jupyter
|
|
28
27
|
require_serial: true
|
|
29
|
-
minimum_pre_commit_version: "2.9.2"
|
|
30
28
|
- id: ruff-format-diff
|
|
31
29
|
name: ruff-format-diff
|
|
32
30
|
description: "Show diff of ruff for formatting"
|
|
@@ -37,7 +35,6 @@ repos:
|
|
|
37
35
|
- pyi
|
|
38
36
|
- jupyter
|
|
39
37
|
require_serial: true
|
|
40
|
-
minimum_pre_commit_version: "2.9.2"
|
|
41
38
|
verbose: true
|
|
42
39
|
- id: ruff-format
|
|
43
40
|
name: ruff-format
|
|
@@ -49,37 +46,36 @@ repos:
|
|
|
49
46
|
- pyi
|
|
50
47
|
- jupyter
|
|
51
48
|
require_serial: true
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
files: '\.(rst|md|markdown|py|tex)$'
|
|
49
|
+
#- id: black-diff
|
|
50
|
+
# name: black-diff
|
|
51
|
+
# entry: black
|
|
52
|
+
# language: system
|
|
53
|
+
# types_or:
|
|
54
|
+
# - python
|
|
55
|
+
# - pyi
|
|
56
|
+
# require_serial: true
|
|
57
|
+
# args:
|
|
58
|
+
# - "--diff"
|
|
59
|
+
# - "--color"
|
|
60
|
+
# - "--quiet"
|
|
61
|
+
# verbose: true
|
|
62
|
+
#- id: black
|
|
63
|
+
# # https://github.com/psf/black-pre-commit-mirror
|
|
64
|
+
# name: black
|
|
65
|
+
# entry: black
|
|
66
|
+
# language: system
|
|
67
|
+
# types_or:
|
|
68
|
+
# - python
|
|
69
|
+
# - pyi
|
|
70
|
+
# require_serial: true
|
|
71
|
+
# args:
|
|
72
|
+
# - "--quiet"
|
|
73
|
+
#- id: blacken-docs
|
|
74
|
+
# # https://github.com/asottile/blacken-docs
|
|
75
|
+
# name: blacken-docs
|
|
76
|
+
# entry: blacken-docs
|
|
77
|
+
# language: system
|
|
78
|
+
# files: '\.(rst|md|markdown|py|tex)$'
|
|
83
79
|
- id: autoflake-diff
|
|
84
80
|
name: autoflake-diff
|
|
85
81
|
entry: autoflake
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyproject-pre-commit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: pre-commit hooks for python projects using pyproject.toml.
|
|
5
5
|
Project-URL: Repository, https://github.com/rcmdnk/pyproject-pre-commit
|
|
6
6
|
Project-URL: Documentation, https://github.com/rcmdnk/pyproject-pre-commit
|
|
@@ -30,17 +30,18 @@ Requires-Dist: mdformat-rustfmt>=0.0.3
|
|
|
30
30
|
Requires-Dist: mdformat-tables>=1.0.0
|
|
31
31
|
Requires-Dist: mdformat-toc>=0.3.0
|
|
32
32
|
Requires-Dist: mdformat-web>=0.2.0
|
|
33
|
-
Requires-Dist: mdformat>=0.7.
|
|
34
|
-
Requires-Dist:
|
|
35
|
-
Requires-Dist:
|
|
36
|
-
Requires-Dist:
|
|
33
|
+
Requires-Dist: mdformat>=0.7.22
|
|
34
|
+
Requires-Dist: numpydoc>=1.9.0
|
|
35
|
+
Requires-Dist: prek>=0.3.2
|
|
36
|
+
Requires-Dist: ruff>=0.15.0
|
|
37
37
|
Requires-Dist: shellcheck-py>=0.9.0.5
|
|
38
|
+
Requires-Dist: ty>=0.0.15
|
|
38
39
|
Requires-Dist: validate-pyproject[all]>=0.22
|
|
39
40
|
Provides-Extra: black
|
|
40
41
|
Requires-Dist: autoflake>=2.2.1; extra == 'black'
|
|
41
42
|
Requires-Dist: autopep8>=2.0.4; extra == 'black'
|
|
42
|
-
Requires-Dist: bandit[toml]>=1.
|
|
43
|
-
Requires-Dist: black>=
|
|
43
|
+
Requires-Dist: bandit[toml]>=1.8.0; extra == 'black'
|
|
44
|
+
Requires-Dist: black>=25.11.0; extra == 'black'
|
|
44
45
|
Requires-Dist: blacken-docs>=1.16.0; extra == 'black'
|
|
45
46
|
Requires-Dist: flake8-annotations-complexity>=0.0.8; extra == 'black'
|
|
46
47
|
Requires-Dist: flake8-bugbear>=24.0.0; extra == 'black'
|
|
@@ -54,13 +55,13 @@ Requires-Dist: flake8-print>=5.0.0; extra == 'black'
|
|
|
54
55
|
Requires-Dist: flake8-pyproject>=1.2.3; extra == 'black'
|
|
55
56
|
Requires-Dist: flake8-rst-docstrings>=0.3.0; extra == 'black'
|
|
56
57
|
Requires-Dist: flake8-string-format>=0.3.0; extra == 'black'
|
|
57
|
-
Requires-Dist: isort>=
|
|
58
|
+
Requires-Dist: isort>=6.1.0; extra == 'black'
|
|
58
59
|
Requires-Dist: pep8-naming>=0.14.0; extra == 'black'
|
|
59
60
|
Requires-Dist: pycodestyle>=2.11.0; extra == 'black'
|
|
60
|
-
Provides-Extra:
|
|
61
|
-
Requires-Dist:
|
|
62
|
-
Provides-Extra:
|
|
63
|
-
Requires-Dist:
|
|
61
|
+
Provides-Extra: mypy
|
|
62
|
+
Requires-Dist: mypy>=1.19.1; extra == 'mypy'
|
|
63
|
+
Provides-Extra: pre-commit
|
|
64
|
+
Requires-Dist: pre-commit>=4.3.0; extra == 'pre-commit'
|
|
64
65
|
Description-Content-Type: text/markdown
|
|
65
66
|
|
|
66
67
|
# pyproject-pre-commit<a name="pyproject-pre-commit"></a>
|
|
@@ -69,6 +70,7 @@ Description-Content-Type: text/markdown
|
|
|
69
70
|
[](https://github.com/rcmdnk/pyproject-pre-commit/tree/coverage)
|
|
70
71
|
|
|
71
72
|
[pre-commit](https://pre-commit.com/) hooks for python projects.
|
|
73
|
+
[prek](https://github.com/j178/prek) also works as well (current default depends on prek).
|
|
72
74
|
|
|
73
75
|
**.pre-commit-hooks.yaml** provides pre-defined ids which you just need to add these ids to your **.pre-commit-config.yaml**.
|
|
74
76
|
|
|
@@ -80,8 +82,9 @@ all necessary tools are installed as dependencies.
|
|
|
80
82
|
- [Requirement](#requirement)
|
|
81
83
|
- [Usage](#usage)
|
|
82
84
|
- [Install pyproject-pre-commit](#install-pyproject-pre-commit)
|
|
85
|
+
- [Optional dependencies](#optional-dependencies)
|
|
83
86
|
- [Prepare .pre-commit-config.yaml](#prepare-pre-commit-configyaml)
|
|
84
|
-
- [Run pre-commit](#run-
|
|
87
|
+
- [Run prek/pre-commit](#run-prekpre-commit)
|
|
85
88
|
- [Available ids](#available-ids)
|
|
86
89
|
- [Options for tools](#options-for-tools)
|
|
87
90
|
- [pyproject.toml](#pyprojecttoml)
|
|
@@ -96,42 +99,73 @@ all necessary tools are installed as dependencies.
|
|
|
96
99
|
|
|
97
100
|
### Install pyproject-pre-commit<a name="install-pyproject-pre-commit"></a>
|
|
98
101
|
|
|
99
|
-
|
|
102
|
+
Using uv:
|
|
100
103
|
|
|
104
|
+
```bash
|
|
105
|
+
$ uv add --group dev pyproject-pre-commit
|
|
101
106
|
```
|
|
102
|
-
|
|
107
|
+
|
|
108
|
+
Using poetry:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
$ poetry add --dev pyproject-pre-commit
|
|
103
112
|
```
|
|
104
113
|
|
|
105
|
-
|
|
114
|
+
Using pip:
|
|
106
115
|
|
|
116
|
+
```bash
|
|
117
|
+
$ pip install pyproject-pre-commit
|
|
107
118
|
```
|
|
108
|
-
|
|
119
|
+
|
|
120
|
+
This will install **pyproject-pre-commit** and
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
"prek>=0.3.2",
|
|
124
|
+
"ruff>=0.15.0",
|
|
125
|
+
"ty>=0.0.15",
|
|
126
|
+
"numpydoc>=1.11.0",
|
|
127
|
+
"shellcheck-py>=0.9.0.5",
|
|
128
|
+
"mdformat>=0.7.22",
|
|
129
|
+
"mdformat-pyproject>=0.0.1",
|
|
130
|
+
"mdformat-ruff>=0.1.3",
|
|
131
|
+
"mdformat-beautysh>=0.1.1",
|
|
132
|
+
"mdformat-config>=0.2.1",
|
|
133
|
+
"mdformat-gofmt>=0.0.2",
|
|
134
|
+
"mdformat-rustfmt>=0.0.3",
|
|
135
|
+
"mdformat-footnote>=0.1.1",
|
|
136
|
+
"mdformat-frontmatter>=2.0.1",
|
|
137
|
+
"mdformat-gfm>=0.3.5",
|
|
138
|
+
"mdformat-tables>=1.0.0",
|
|
139
|
+
"mdformat-web>=0.2.0",
|
|
140
|
+
"mdformat-toc>=0.3.0",
|
|
141
|
+
"validate-pyproject[all]>=0.22",
|
|
109
142
|
```
|
|
110
143
|
|
|
111
|
-
|
|
144
|
+
### Optional dependencies<a name="optional-dependencies"></a>
|
|
112
145
|
|
|
113
|
-
|
|
146
|
+
if you want to install `pre-commit`, do:
|
|
114
147
|
|
|
115
148
|
```
|
|
116
|
-
$
|
|
149
|
+
$ uv add --dev pyproject-pre-commit[pre-commit]
|
|
117
150
|
```
|
|
118
151
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
If you wish to install all, do:
|
|
152
|
+
If you want to use `black`/`autoflake`/`autopep8`/`flake8`/`isort`/`bandit` for linting/formatting, do:
|
|
122
153
|
|
|
123
154
|
```
|
|
124
|
-
$
|
|
155
|
+
$ uv add --dev pyproject-pre-commit[black]
|
|
125
156
|
```
|
|
126
157
|
|
|
127
|
-
If you
|
|
158
|
+
If you need `mypy`, do:
|
|
128
159
|
|
|
129
160
|
```
|
|
130
|
-
$
|
|
161
|
+
$ uv add --dev pyproject-pre-commit[mypy]
|
|
131
162
|
```
|
|
132
163
|
|
|
133
|
-
|
|
134
|
-
|
|
164
|
+
If you wish to install all, do:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
$ uv add --dev pyproject-pre-commit[all]
|
|
168
|
+
```
|
|
135
169
|
|
|
136
170
|
### Prepare .pre-commit-config.yaml<a name="prepare-pre-commit-configyaml"></a>
|
|
137
171
|
|
|
@@ -140,20 +174,14 @@ Add **https://github.com/rcmdnk/pyproject-pre-commit** to your **.pre-commit-con
|
|
|
140
174
|
```yaml
|
|
141
175
|
repos:
|
|
142
176
|
- repo: https://github.com/rcmdnk/pyproject-pre-commit
|
|
143
|
-
rev: v0.
|
|
177
|
+
rev: v0.6.0
|
|
144
178
|
hooks:
|
|
145
|
-
- id:
|
|
146
|
-
- id:
|
|
147
|
-
- id:
|
|
148
|
-
- id:
|
|
149
|
-
- id:
|
|
150
|
-
- id:
|
|
151
|
-
- id: autopep8
|
|
152
|
-
- id: isort-diff
|
|
153
|
-
- id: isort
|
|
154
|
-
- id: flake8
|
|
155
|
-
- id: bandit
|
|
156
|
-
- id: mypy
|
|
179
|
+
- id: ruff-lint-diff
|
|
180
|
+
- id: ruff-lint
|
|
181
|
+
- id: ruff-format-diff
|
|
182
|
+
- id: ruff-format
|
|
183
|
+
- id: ty
|
|
184
|
+
- id: numpydoc-validation
|
|
157
185
|
- id: shellcheck
|
|
158
186
|
- id: mdformat-check
|
|
159
187
|
- id: mdformat
|
|
@@ -170,7 +198,7 @@ tools installed in your working environment.
|
|
|
170
198
|
This can be made by `ppc` command:
|
|
171
199
|
|
|
172
200
|
```
|
|
173
|
-
$ ppc
|
|
201
|
+
$ ppc pre-commit > .pre-commit-config.yaml
|
|
174
202
|
```
|
|
175
203
|
|
|
176
204
|
> [!NOTE]
|
|
@@ -184,18 +212,26 @@ $ ppc --pre-commit |grep -v "^repos:" >> .pre-commit-config.yaml
|
|
|
184
212
|
|
|
185
213
|
You may want to modify after adding these configurations.
|
|
186
214
|
|
|
187
|
-
To use `
|
|
215
|
+
To use `black`, `flake8`, `isort` and `mypy`, instead of `ruff`/`ty`, add following hooks:
|
|
188
216
|
|
|
189
217
|
```yaml
|
|
190
218
|
repos:
|
|
191
219
|
- repo: https://github.com/rcmdnk/pyproject-pre-commit
|
|
192
|
-
rev: v0.
|
|
220
|
+
rev: v0.6.0
|
|
193
221
|
hooks:
|
|
194
|
-
- id:
|
|
195
|
-
- id:
|
|
196
|
-
- id:
|
|
197
|
-
- id:
|
|
222
|
+
- id: black-diff
|
|
223
|
+
- id: black
|
|
224
|
+
- id: blacken-docs
|
|
225
|
+
- id: autoflake-diff
|
|
226
|
+
- id: autoflake
|
|
227
|
+
- id: autopep8-diff
|
|
228
|
+
- id: autopep8
|
|
229
|
+
- id: isort-diff
|
|
230
|
+
- id: isort
|
|
231
|
+
- id: flake8
|
|
232
|
+
- id: bandit
|
|
198
233
|
- id: mypy
|
|
234
|
+
- id: numpydoc-validation
|
|
199
235
|
- id: shellcheck
|
|
200
236
|
- id: mdformat-check
|
|
201
237
|
- id: mdformat
|
|
@@ -206,29 +242,31 @@ repos:
|
|
|
206
242
|
This can be made by `ppc` command:
|
|
207
243
|
|
|
208
244
|
```
|
|
209
|
-
$ ppc
|
|
245
|
+
$ ppc pre-commit --black --mypy > .pre-commit-config.yaml
|
|
210
246
|
```
|
|
211
247
|
|
|
212
|
-
### Run pre-commit<a name="run-
|
|
248
|
+
### Run prek/pre-commit<a name="run-prekpre-commit"></a>
|
|
213
249
|
|
|
214
|
-
`
|
|
250
|
+
`prek` command is installed as dependencies of **pyproject-pre-commit** package.
|
|
215
251
|
|
|
216
|
-
After installing **pyproject-pre-commit** package, you can run `
|
|
252
|
+
After installing **pyproject-pre-commit** package, you can run `prek` command.
|
|
217
253
|
|
|
218
254
|
First, install pre-commit hooks by:
|
|
219
255
|
|
|
220
256
|
```
|
|
221
|
-
$
|
|
257
|
+
$ prek install
|
|
222
258
|
```
|
|
223
259
|
|
|
224
260
|
then you can run pre-commit by:
|
|
225
261
|
|
|
226
262
|
```
|
|
227
|
-
$
|
|
263
|
+
$ prek run -a
|
|
228
264
|
```
|
|
229
265
|
|
|
230
266
|
> [!NOTE]
|
|
231
|
-
> If you are using
|
|
267
|
+
> If you are using uv, run `uv run pre-commit ... `
|
|
268
|
+
|
|
269
|
+
If you want to use `pre-commit` command, install `pyproject-pre-commit[pre-commit]` and use `pre-commit` command.
|
|
232
270
|
|
|
233
271
|
## Available ids<a name="available-ids"></a>
|
|
234
272
|
|
|
@@ -237,6 +275,10 @@ You can find ids in **.pre-commit-hooks.yaml**.
|
|
|
237
275
|
There are ids for following tools:
|
|
238
276
|
|
|
239
277
|
- For Python
|
|
278
|
+
- [ruff-lint-diff](https://docs.astral.sh/ruff/): Just show ruff check result.
|
|
279
|
+
- [ruff-lint](https://docs.astral.sh/ruff/): Fix by ruff for lint.
|
|
280
|
+
- [ruff-format-diff](https://docs.astral.sh/ruff/): Just show ruff format result.
|
|
281
|
+
- [ruff-format](https://docs.astral.sh/ruff/): Format by ruff.
|
|
240
282
|
- [black-diff](https://black.readthedocs.io/en/stable): Just show Black result.
|
|
241
283
|
- [black](https://black.readthedocs.io/en/stable): Black: The uncompromising Python code formatter.
|
|
242
284
|
- [blacken-docs](https://github.com/adamchainz/blacken-docs): Run `black` on python code blocks in documentation files.
|
|
@@ -263,11 +305,8 @@ There are ids for following tools:
|
|
|
263
305
|
- [pep8-naming](https://github.com/PyCQA/pep8-naming)
|
|
264
306
|
- [pycodestyle](https://pycodestyle.pycqa.org/en/latest/)
|
|
265
307
|
- [bandit](https://github.com/PyCQA/bandit): Bandit is a tool for finding common security issues in Python code.
|
|
308
|
+
- [ty](https://docs.astral.sh/ty/): An extremely fast Python type checker and language server, written in Rust.
|
|
266
309
|
- [mypy](https://www.mypy-lang.org/): Mypy is a static type checker for Python.
|
|
267
|
-
- [ruff-lint-diff](https://docs.astral.sh/ruff/): Just show ruff check result.
|
|
268
|
-
- [ruff-lint](https://docs.astral.sh/ruff/): Fix by ruff for lint.
|
|
269
|
-
- [ruff-format-diff](https://docs.astral.sh/ruff/): Just show ruff format result.
|
|
270
|
-
- [ruff-format](https://docs.astral.sh/ruff/): Format by ruff.
|
|
271
310
|
- For Shell script
|
|
272
311
|
- [shellcheck](https://www.shellcheck.net/): ShellCheck - A shell script static analysis tool
|
|
273
312
|
- For Markdown
|
|
@@ -313,7 +352,7 @@ $ ppc --pyproject >> pyproject.toml
|
|
|
313
352
|
or
|
|
314
353
|
|
|
315
354
|
```
|
|
316
|
-
$ ppc --pyproject --
|
|
355
|
+
$ ppc --pyproject --black --mypy >> pyproject.toml
|
|
317
356
|
```
|
|
318
357
|
|
|
319
358
|
You may want to modify after adding these configurations.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
[](https://github.com/rcmdnk/pyproject-pre-commit/tree/coverage)
|
|
5
5
|
|
|
6
6
|
[pre-commit](https://pre-commit.com/) hooks for python projects.
|
|
7
|
+
[prek](https://github.com/j178/prek) also works as well (current default depends on prek).
|
|
7
8
|
|
|
8
9
|
**.pre-commit-hooks.yaml** provides pre-defined ids which you just need to add these ids to your **.pre-commit-config.yaml**.
|
|
9
10
|
|
|
@@ -15,8 +16,9 @@ all necessary tools are installed as dependencies.
|
|
|
15
16
|
- [Requirement](#requirement)
|
|
16
17
|
- [Usage](#usage)
|
|
17
18
|
- [Install pyproject-pre-commit](#install-pyproject-pre-commit)
|
|
19
|
+
- [Optional dependencies](#optional-dependencies)
|
|
18
20
|
- [Prepare .pre-commit-config.yaml](#prepare-pre-commit-configyaml)
|
|
19
|
-
- [Run pre-commit](#run-
|
|
21
|
+
- [Run prek/pre-commit](#run-prekpre-commit)
|
|
20
22
|
- [Available ids](#available-ids)
|
|
21
23
|
- [Options for tools](#options-for-tools)
|
|
22
24
|
- [pyproject.toml](#pyprojecttoml)
|
|
@@ -31,42 +33,73 @@ all necessary tools are installed as dependencies.
|
|
|
31
33
|
|
|
32
34
|
### Install pyproject-pre-commit<a name="install-pyproject-pre-commit"></a>
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
Using uv:
|
|
35
37
|
|
|
38
|
+
```bash
|
|
39
|
+
$ uv add --group dev pyproject-pre-commit
|
|
36
40
|
```
|
|
37
|
-
|
|
41
|
+
|
|
42
|
+
Using poetry:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
$ poetry add --dev pyproject-pre-commit
|
|
38
46
|
```
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
Using pip:
|
|
41
49
|
|
|
50
|
+
```bash
|
|
51
|
+
$ pip install pyproject-pre-commit
|
|
42
52
|
```
|
|
43
|
-
|
|
53
|
+
|
|
54
|
+
This will install **pyproject-pre-commit** and
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
"prek>=0.3.2",
|
|
58
|
+
"ruff>=0.15.0",
|
|
59
|
+
"ty>=0.0.15",
|
|
60
|
+
"numpydoc>=1.11.0",
|
|
61
|
+
"shellcheck-py>=0.9.0.5",
|
|
62
|
+
"mdformat>=0.7.22",
|
|
63
|
+
"mdformat-pyproject>=0.0.1",
|
|
64
|
+
"mdformat-ruff>=0.1.3",
|
|
65
|
+
"mdformat-beautysh>=0.1.1",
|
|
66
|
+
"mdformat-config>=0.2.1",
|
|
67
|
+
"mdformat-gofmt>=0.0.2",
|
|
68
|
+
"mdformat-rustfmt>=0.0.3",
|
|
69
|
+
"mdformat-footnote>=0.1.1",
|
|
70
|
+
"mdformat-frontmatter>=2.0.1",
|
|
71
|
+
"mdformat-gfm>=0.3.5",
|
|
72
|
+
"mdformat-tables>=1.0.0",
|
|
73
|
+
"mdformat-web>=0.2.0",
|
|
74
|
+
"mdformat-toc>=0.3.0",
|
|
75
|
+
"validate-pyproject[all]>=0.22",
|
|
44
76
|
```
|
|
45
77
|
|
|
46
|
-
|
|
78
|
+
### Optional dependencies<a name="optional-dependencies"></a>
|
|
47
79
|
|
|
48
|
-
|
|
80
|
+
if you want to install `pre-commit`, do:
|
|
49
81
|
|
|
50
82
|
```
|
|
51
|
-
$
|
|
83
|
+
$ uv add --dev pyproject-pre-commit[pre-commit]
|
|
52
84
|
```
|
|
53
85
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
If you wish to install all, do:
|
|
86
|
+
If you want to use `black`/`autoflake`/`autopep8`/`flake8`/`isort`/`bandit` for linting/formatting, do:
|
|
57
87
|
|
|
58
88
|
```
|
|
59
|
-
$
|
|
89
|
+
$ uv add --dev pyproject-pre-commit[black]
|
|
60
90
|
```
|
|
61
91
|
|
|
62
|
-
If you
|
|
92
|
+
If you need `mypy`, do:
|
|
63
93
|
|
|
64
94
|
```
|
|
65
|
-
$
|
|
95
|
+
$ uv add --dev pyproject-pre-commit[mypy]
|
|
66
96
|
```
|
|
67
97
|
|
|
68
|
-
|
|
69
|
-
|
|
98
|
+
If you wish to install all, do:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
$ uv add --dev pyproject-pre-commit[all]
|
|
102
|
+
```
|
|
70
103
|
|
|
71
104
|
### Prepare .pre-commit-config.yaml<a name="prepare-pre-commit-configyaml"></a>
|
|
72
105
|
|
|
@@ -75,20 +108,14 @@ Add **https://github.com/rcmdnk/pyproject-pre-commit** to your **.pre-commit-con
|
|
|
75
108
|
```yaml
|
|
76
109
|
repos:
|
|
77
110
|
- repo: https://github.com/rcmdnk/pyproject-pre-commit
|
|
78
|
-
rev: v0.
|
|
111
|
+
rev: v0.6.0
|
|
79
112
|
hooks:
|
|
80
|
-
- id:
|
|
81
|
-
- id:
|
|
82
|
-
- id:
|
|
83
|
-
- id:
|
|
84
|
-
- id:
|
|
85
|
-
- id:
|
|
86
|
-
- id: autopep8
|
|
87
|
-
- id: isort-diff
|
|
88
|
-
- id: isort
|
|
89
|
-
- id: flake8
|
|
90
|
-
- id: bandit
|
|
91
|
-
- id: mypy
|
|
113
|
+
- id: ruff-lint-diff
|
|
114
|
+
- id: ruff-lint
|
|
115
|
+
- id: ruff-format-diff
|
|
116
|
+
- id: ruff-format
|
|
117
|
+
- id: ty
|
|
118
|
+
- id: numpydoc-validation
|
|
92
119
|
- id: shellcheck
|
|
93
120
|
- id: mdformat-check
|
|
94
121
|
- id: mdformat
|
|
@@ -105,7 +132,7 @@ tools installed in your working environment.
|
|
|
105
132
|
This can be made by `ppc` command:
|
|
106
133
|
|
|
107
134
|
```
|
|
108
|
-
$ ppc
|
|
135
|
+
$ ppc pre-commit > .pre-commit-config.yaml
|
|
109
136
|
```
|
|
110
137
|
|
|
111
138
|
> [!NOTE]
|
|
@@ -119,18 +146,26 @@ $ ppc --pre-commit |grep -v "^repos:" >> .pre-commit-config.yaml
|
|
|
119
146
|
|
|
120
147
|
You may want to modify after adding these configurations.
|
|
121
148
|
|
|
122
|
-
To use `
|
|
149
|
+
To use `black`, `flake8`, `isort` and `mypy`, instead of `ruff`/`ty`, add following hooks:
|
|
123
150
|
|
|
124
151
|
```yaml
|
|
125
152
|
repos:
|
|
126
153
|
- repo: https://github.com/rcmdnk/pyproject-pre-commit
|
|
127
|
-
rev: v0.
|
|
154
|
+
rev: v0.6.0
|
|
128
155
|
hooks:
|
|
129
|
-
- id:
|
|
130
|
-
- id:
|
|
131
|
-
- id:
|
|
132
|
-
- id:
|
|
156
|
+
- id: black-diff
|
|
157
|
+
- id: black
|
|
158
|
+
- id: blacken-docs
|
|
159
|
+
- id: autoflake-diff
|
|
160
|
+
- id: autoflake
|
|
161
|
+
- id: autopep8-diff
|
|
162
|
+
- id: autopep8
|
|
163
|
+
- id: isort-diff
|
|
164
|
+
- id: isort
|
|
165
|
+
- id: flake8
|
|
166
|
+
- id: bandit
|
|
133
167
|
- id: mypy
|
|
168
|
+
- id: numpydoc-validation
|
|
134
169
|
- id: shellcheck
|
|
135
170
|
- id: mdformat-check
|
|
136
171
|
- id: mdformat
|
|
@@ -141,29 +176,31 @@ repos:
|
|
|
141
176
|
This can be made by `ppc` command:
|
|
142
177
|
|
|
143
178
|
```
|
|
144
|
-
$ ppc
|
|
179
|
+
$ ppc pre-commit --black --mypy > .pre-commit-config.yaml
|
|
145
180
|
```
|
|
146
181
|
|
|
147
|
-
### Run pre-commit<a name="run-
|
|
182
|
+
### Run prek/pre-commit<a name="run-prekpre-commit"></a>
|
|
148
183
|
|
|
149
|
-
`
|
|
184
|
+
`prek` command is installed as dependencies of **pyproject-pre-commit** package.
|
|
150
185
|
|
|
151
|
-
After installing **pyproject-pre-commit** package, you can run `
|
|
186
|
+
After installing **pyproject-pre-commit** package, you can run `prek` command.
|
|
152
187
|
|
|
153
188
|
First, install pre-commit hooks by:
|
|
154
189
|
|
|
155
190
|
```
|
|
156
|
-
$
|
|
191
|
+
$ prek install
|
|
157
192
|
```
|
|
158
193
|
|
|
159
194
|
then you can run pre-commit by:
|
|
160
195
|
|
|
161
196
|
```
|
|
162
|
-
$
|
|
197
|
+
$ prek run -a
|
|
163
198
|
```
|
|
164
199
|
|
|
165
200
|
> [!NOTE]
|
|
166
|
-
> If you are using
|
|
201
|
+
> If you are using uv, run `uv run pre-commit ... `
|
|
202
|
+
|
|
203
|
+
If you want to use `pre-commit` command, install `pyproject-pre-commit[pre-commit]` and use `pre-commit` command.
|
|
167
204
|
|
|
168
205
|
## Available ids<a name="available-ids"></a>
|
|
169
206
|
|
|
@@ -172,6 +209,10 @@ You can find ids in **.pre-commit-hooks.yaml**.
|
|
|
172
209
|
There are ids for following tools:
|
|
173
210
|
|
|
174
211
|
- For Python
|
|
212
|
+
- [ruff-lint-diff](https://docs.astral.sh/ruff/): Just show ruff check result.
|
|
213
|
+
- [ruff-lint](https://docs.astral.sh/ruff/): Fix by ruff for lint.
|
|
214
|
+
- [ruff-format-diff](https://docs.astral.sh/ruff/): Just show ruff format result.
|
|
215
|
+
- [ruff-format](https://docs.astral.sh/ruff/): Format by ruff.
|
|
175
216
|
- [black-diff](https://black.readthedocs.io/en/stable): Just show Black result.
|
|
176
217
|
- [black](https://black.readthedocs.io/en/stable): Black: The uncompromising Python code formatter.
|
|
177
218
|
- [blacken-docs](https://github.com/adamchainz/blacken-docs): Run `black` on python code blocks in documentation files.
|
|
@@ -198,11 +239,8 @@ There are ids for following tools:
|
|
|
198
239
|
- [pep8-naming](https://github.com/PyCQA/pep8-naming)
|
|
199
240
|
- [pycodestyle](https://pycodestyle.pycqa.org/en/latest/)
|
|
200
241
|
- [bandit](https://github.com/PyCQA/bandit): Bandit is a tool for finding common security issues in Python code.
|
|
242
|
+
- [ty](https://docs.astral.sh/ty/): An extremely fast Python type checker and language server, written in Rust.
|
|
201
243
|
- [mypy](https://www.mypy-lang.org/): Mypy is a static type checker for Python.
|
|
202
|
-
- [ruff-lint-diff](https://docs.astral.sh/ruff/): Just show ruff check result.
|
|
203
|
-
- [ruff-lint](https://docs.astral.sh/ruff/): Fix by ruff for lint.
|
|
204
|
-
- [ruff-format-diff](https://docs.astral.sh/ruff/): Just show ruff format result.
|
|
205
|
-
- [ruff-format](https://docs.astral.sh/ruff/): Format by ruff.
|
|
206
244
|
- For Shell script
|
|
207
245
|
- [shellcheck](https://www.shellcheck.net/): ShellCheck - A shell script static analysis tool
|
|
208
246
|
- For Markdown
|
|
@@ -248,7 +286,7 @@ $ ppc --pyproject >> pyproject.toml
|
|
|
248
286
|
or
|
|
249
287
|
|
|
250
288
|
```
|
|
251
|
-
$ ppc --pyproject --
|
|
289
|
+
$ ppc --pyproject --black --mypy >> pyproject.toml
|
|
252
290
|
```
|
|
253
291
|
|
|
254
292
|
You may want to modify after adding these configurations.
|