pyproject-pre-commit 0.2.5__py3-none-any.whl → 0.3.1__py3-none-any.whl

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.
@@ -3,9 +3,22 @@ import sys
3
3
  from . import __version__
4
4
 
5
5
 
6
- def pre_commit() -> None:
7
- print( # noqa: T201
8
- f"""repos:
6
+ def pre_commit(is_ruff: bool) -> None:
7
+ if is_ruff:
8
+ print( # noqa: T201
9
+ f"""repos:
10
+ - repo: https://github.com/rcmdnk/pyproject-pre-commit
11
+ rev: v{__version__}
12
+ hooks:
13
+ - id: ruff-lint-diff
14
+ - id: ruff-lint
15
+ - id: ruff-format-diff
16
+ - id: ruff-format
17
+ """
18
+ )
19
+ else:
20
+ print( # noqa: T201
21
+ f"""repos:
9
22
  - repo: https://github.com/rcmdnk/pyproject-pre-commit
10
23
  rev: v{__version__}
11
24
  hooks:
@@ -20,7 +33,10 @@ def pre_commit() -> None:
20
33
  - id: isort
21
34
  - id: flake8
22
35
  - id: bandit
23
- - id: mypy
36
+ """
37
+ )
38
+ print( # noqa: T201
39
+ """- id: mypy
24
40
  - id: numpydoc-validation
25
41
  - id: shellcheck
26
42
  - id: mdformat-check
@@ -29,9 +45,57 @@ def pre_commit() -> None:
29
45
  )
30
46
 
31
47
 
32
- def pyproject() -> None:
33
- print( # noqa: T201
34
- """[tool.black]
48
+ def pyproject(is_ruff: bool) -> None:
49
+ if is_ruff:
50
+ print( # noqa: T201
51
+ """[tool.ruff]
52
+ line-length = 79
53
+ # quote-style = "single"
54
+
55
+ [tool.ruff.lint]
56
+ ## select = ["ALL"]
57
+ ## select = ["E4", "E7", "E9", "F"] # default, black compatible
58
+ select = [ # similar options to black, flake8 + plugins, isort etc...)
59
+ #"E4", # Import (comparable to black)
60
+ #"E7", # Indentation (comparable to black)
61
+ #"E9", # Blank line (comparable to black)
62
+ "F", # String (comparable to black)
63
+ "I", # Import order (comparable to isort)
64
+ "S", # flake8-bandit (comparable to bandit)
65
+ "B", # flake8-bugbear
66
+ "A", # flake8-builtins
67
+ "C4", # flake8-comprehensions
68
+ "T10", # flake8-debugger
69
+ "EXE", # flake8-executable
70
+ "T20", # flake8-print
71
+ "N", # pep8-naming
72
+ "E", # pycodestyle
73
+ "W", # pycodestyle
74
+ "C90", # mccabe
75
+ ]
76
+
77
+ ignore = [
78
+ "E203", # Not PEP8 compliant and black insert space around slice: [Frequently Asked Questions - Black 22.12.0 documentation](https://black.readthedocs.io/en/stable/faq.html#why-are-flake8-s-e203-and-w503-violated)
79
+ "E501", # Line too long. Disable it to allow long lines of comments and print lines which black allows.
80
+ # "E704", # NOT in ruff. multiple statements on one line (def). This is inconsistent with black >= 24.1.1 (see ttps://github.com/psf/black/pull/3796)
81
+ # "W503", # NOT in ruff. is the counter part of W504, which follows current PEP8: [Line break occurred before a binary operator (W503)](https://www.flake8rules.com/rules/W503.html)
82
+ "D100", "D102", "D103", "D104", "D105", "D106", # Missing docstrings other than class (D101)
83
+ "D401", # First line should be in imperative mood
84
+ ]
85
+
86
+ [tool.ruff.lint.per-file-ignores]
87
+ "tests/**" = ["S101"]
88
+
89
+ [tool.ruff.lint.mccabe]
90
+ max-complexity = 10
91
+
92
+ [tool.ruff.format]
93
+ docstring-code-format = true
94
+ """
95
+ )
96
+ else:
97
+ print( # noqa: T201
98
+ """[tool.black]
35
99
  line-length = 79
36
100
 
37
101
  [tool.autoflake]
@@ -58,8 +122,10 @@ docstring-convention = "numpy"
58
122
  [tool.bandit]
59
123
  targets = "."
60
124
  exclude = "tests"
61
-
62
- [tool.mypy]
125
+ """
126
+ )
127
+ print( # noqa: T201
128
+ """[tool.mypy]
63
129
  files = "src/**/*.py"
64
130
  strict = true
65
131
  warn_return_any = false
@@ -72,19 +138,17 @@ non_interactive = true
72
138
 
73
139
 
74
140
  def main() -> None:
141
+ usage = "Usage: ppc <--pre-commit | --pyproject> [--ruff] [--black]"
75
142
  if len(sys.argv) != 2:
76
- print( # noqa: T201
77
- "Please specify only one of --pre-commit and --pyproject."
78
- )
143
+ print(usage) # noqa: T201
79
144
  sys.exit(1)
80
- if sys.argv[1] == "--pre-commit":
81
- pre_commit()
82
- elif sys.argv[1] == "--pyproject":
83
- pyproject()
145
+ is_ruff = "--ruff" in sys.argv
146
+ if "--pre-commit" in sys.argv:
147
+ pre_commit(is_ruff)
148
+ elif "--pyproject" in sys.argv:
149
+ pyproject(is_ruff)
84
150
  else:
85
- print( # noqa: T201
86
- "Please specify only one of --pre-commit and --pyproject."
87
- )
151
+ print(usage) # noqa: T201
88
152
  sys.exit(1)
89
153
 
90
154
 
@@ -1,56 +1,49 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: pyproject-pre-commit
3
- Version: 0.2.5
3
+ Version: 0.3.1
4
4
  Summary: pre-commit hooks for python projects using pyproject.toml.
5
- Home-page: https://github.com/rcmdnk/pyproject-pre-commit
6
- License: Apache-2.0
7
- Keywords: pre-commit,pyproject.toml,poetry
8
- Author: rcmdnk
9
- Author-email: rcmdnk@gmail.com
10
- Requires-Python: >=3.9.0,<4.0.0
5
+ Author-email: rcmdnk <rcmdnk@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Keywords: pre-commit,pyproject.toml,uv
11
9
  Classifier: Development Status :: 3 - Alpha
12
10
  Classifier: Environment :: Console
13
11
  Classifier: Intended Audience :: Developers
14
- Classifier: License :: OSI Approved :: Apache Software License
15
12
  Classifier: Operating System :: OS Independent
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.9
18
- Classifier: Programming Language :: Python :: 3.10
19
- Classifier: Programming Language :: Python :: 3.11
20
- Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Programming Language :: Python :: 3.13
22
13
  Classifier: Topic :: Software Development
23
14
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
15
  Classifier: Topic :: Utilities
25
- Requires-Dist: autoflake (>=2.2.1,<3.0.0)
26
- Requires-Dist: autopep8 (>=2.0.4,<3.0.0)
27
- Requires-Dist: bandit[toml] (>=1.7.5,<2.0.0)
28
- Requires-Dist: black (>=24.3.0,<25.0.0)
29
- Requires-Dist: blacken-docs (>=1.16.0,<2.0.0)
30
- Requires-Dist: flake8-annotations-complexity (>=0.0.8,<0.0.9)
31
- Requires-Dist: flake8-bugbear (>=24.0.0,<25.0.0)
32
- Requires-Dist: flake8-builtins (>=2.1.0,<3.0.0)
33
- Requires-Dist: flake8-comprehensions (>=3.14.0,<4.0.0)
34
- Requires-Dist: flake8-debugger (>=4.1.2,<5.0.0)
35
- Requires-Dist: flake8-docstrings (>=1.7.0,<2.0.0)
36
- Requires-Dist: flake8-executable (>=2.1.3,<3.0.0)
37
- Requires-Dist: flake8-pep3101 (>=2.0.0,<3.0.0)
38
- Requires-Dist: flake8-print (>=5.0.0,<6.0.0)
39
- Requires-Dist: flake8-pyproject (>=1.2.3,<2.0.0)
40
- Requires-Dist: flake8-rst-docstrings (>=0.3.0,<0.4.0)
41
- Requires-Dist: flake8-string-format (>=0.3.0,<0.4.0)
42
- Requires-Dist: isort (>=5.12.0,<6.0.0)
43
- Requires-Dist: mdformat (>=0.7.17,<0.8.0)
44
- Requires-Dist: mdformat-footnote (>=0.1.1,<0.2.0)
45
- Requires-Dist: mdformat-frontmatter (>=2.0.1,<3.0.0)
46
- Requires-Dist: mdformat-gfm (>=0.3.5,<0.4.0)
47
- Requires-Dist: mypy (>=1.5.1,<2.0.0)
48
- Requires-Dist: numpydoc (>=1.8.0,<2.0.0)
49
- Requires-Dist: pep8-naming (>=0.14.0,<0.15.0)
50
- Requires-Dist: pre-commit (>=4.0.0,<5.0.0)
51
- Requires-Dist: pycodestyle (>=2.11.0,<3.0.0)
52
- Requires-Dist: shellcheck-py (>=0.9.0.5,<0.10.0.0)
53
- Project-URL: Repository, https://github.com/rcmdnk/pyproject-pre-commit
16
+ Requires-Python: >=3.9.0
17
+ Requires-Dist: autoflake>=2.2.1
18
+ Requires-Dist: autopep8>=2.0.4
19
+ Requires-Dist: bandit[toml]>=1.7.5
20
+ Requires-Dist: black>=24.3.0
21
+ Requires-Dist: blacken-docs>=1.16.0
22
+ Requires-Dist: flake8-annotations-complexity>=0.0.8
23
+ Requires-Dist: flake8-bugbear>=24.0.0
24
+ Requires-Dist: flake8-builtins>=2.1.0
25
+ Requires-Dist: flake8-comprehensions>=3.14.0
26
+ Requires-Dist: flake8-debugger>=4.1.2
27
+ Requires-Dist: flake8-docstrings>=1.7.0
28
+ Requires-Dist: flake8-executable>=2.1.3
29
+ Requires-Dist: flake8-pep3101>=2.0.0
30
+ Requires-Dist: flake8-print>=5.0.0
31
+ Requires-Dist: flake8-pyproject>=1.2.3
32
+ Requires-Dist: flake8-rst-docstrings>=0.3.0
33
+ Requires-Dist: flake8-string-format>=0.3.0
34
+ Requires-Dist: isort>=5.12.0
35
+ Requires-Dist: mdformat-footnote>=0.1.1
36
+ Requires-Dist: mdformat-frontmatter>=2.0.1
37
+ Requires-Dist: mdformat-gfm>=0.3.5
38
+ Requires-Dist: mdformat>=0.7.17
39
+ Requires-Dist: mypy>=1.5.1
40
+ Requires-Dist: numpydoc>=1.8.0
41
+ Requires-Dist: pep8-naming>=0.14.0
42
+ Requires-Dist: pre-commit>=4.0.0
43
+ Requires-Dist: pycodestyle>=2.11.0
44
+ Requires-Dist: shellcheck-py>=0.9.0.5
45
+ Provides-Extra: ruff
46
+ Requires-Dist: ruff>=0.7.2; extra == 'ruff'
54
47
  Description-Content-Type: text/markdown
55
48
 
56
49
  # pyproject-pre-commit
@@ -67,7 +60,7 @@ all necessary tools are installed as dependencies.
67
60
 
68
61
  ## Requirement
69
62
 
70
- - Python >= 3.8.1
63
+ - Python >= 3.9.0
71
64
  - Poetry (For development)
72
65
 
73
66
  ## Usage
@@ -91,6 +84,18 @@ $ pip install pyproject-pre-commit
91
84
  This will install tools for pre-commit hooks in your working environment,
92
85
  so that you can use these tools, such as black, directly.
93
86
 
87
+ ### Install pyproject-pre-commit with ruff
88
+
89
+ If you want to use ruff, you can install pyproject-pre-commit with ruff option.
90
+
91
+ ```
92
+ $ poetry add --group dev "pyproject-pre-commit[ruff]"
93
+ ```
94
+
95
+ ```
96
+ $ pip install pyproject-pre-commit[ruff]
97
+ ```
98
+
94
99
  ### Prepare .pre-commit-config.yaml
95
100
 
96
101
  Add **https://github.com/rcmdnk/pyproject-pre-commit** to your **.pre-commit-config.yaml**, like:
@@ -98,7 +103,7 @@ Add **https://github.com/rcmdnk/pyproject-pre-commit** to your **.pre-commit-con
98
103
  ```yaml
99
104
  repos:
100
105
  - repo: https://github.com/rcmdnk/pyproject-pre-commit
101
- rev: v0.1.1
106
+ rev: v0.3.0
102
107
  hooks:
103
108
  - id: black-diff
104
109
  - id: black
@@ -140,6 +145,29 @@ $ ppc --pre-commit |grep -v "^repos:" >> .pre-commit-config.yaml
140
145
 
141
146
  You may want to modify after adding these configurations.
142
147
 
148
+ To use `ruff` instead of such as `black`, `flake8`, `isort`, add following hooks:
149
+
150
+ ```yaml
151
+ repos:
152
+ - repo: https://github.com/rcmdnk/pyproject-pre-commit
153
+ rev: v0.3.0
154
+ hooks:
155
+ - id: ruff-lint-diff
156
+ - id: ruff-lint
157
+ - id: ruff-format-diff
158
+ - id: ruff-format
159
+ - id: mypy
160
+ - id: shellcheck
161
+ - id: mdformat-check
162
+ - id: mdformat
163
+ ```
164
+
165
+ This can be made by `ppc` command:
166
+
167
+ ```
168
+ $ ppc --pre-commit --ruff > .pre-commit-config.yaml
169
+ ```
170
+
143
171
  ### Run pre-commit
144
172
 
145
173
  `pre-commit` command is installed as dependencies of **pyproject-pre-commit** package.
@@ -168,14 +196,14 @@ You can find ids in **.pre-commit-hooks.yaml**.
168
196
  There are ids for following tools:
169
197
 
170
198
  - For Python
171
- - black-diff: Just show Black result.
199
+ - [black-diff](https://black.readthedocs.io/en/stable): Just show Black result.
172
200
  - [black](https://black.readthedocs.io/en/stable): Black: The uncompromising Python code formatter.
173
201
  - [blacken-docs](https://github.com/adamchainz/blacken-docs): Run `black` on python code blocks in documentation files.
174
- - autoflake-diff: Just show autoflake result.
202
+ - [autoflake-diff](https://github.com/PyCQA/autoflake): Just show autoflake result.
175
203
  - [autoflake](https://github.com/PyCQA/autoflake): autoflake removes unused imports and unused variables from Python code.
176
- - autopep8-diff: Just show autopep8.
204
+ - [autopep8-diff](https://github.com/hhatto/autopep8): Just show autopep8.
177
205
  - [autopep8](https://github.com/hhatto/autopep8): autopep8 automatically formats Python code to conform to the PEP 8 style guide.
178
- - isort-diff: Just show isort result.
206
+ - [isort-diff](https://github.com/PyCQA/isort): Just show isort result.
179
207
  - [isort](https://github.com/PyCQA/isort): isort your imports, so you don't have to.
180
208
  - [flake8](https://github.com/PyCQA/flake8): `flake8` is a command-line utility for enforcing style consistency across Python projects.
181
209
  - With following plugins:
@@ -195,6 +223,10 @@ There are ids for following tools:
195
223
  - [pycodestyle](https://pycodestyle.pycqa.org/en/latest/)
196
224
  - [bandit](https://github.com/PyCQA/bandit): Bandit is a tool for finding common security issues in Python code.
197
225
  - [mypy](https://www.mypy-lang.org/): Mypy is a static type checker for Python.
226
+ - [ruff-lint-diff](https://docs.astral.sh/ruff/): Just show ruff check result.
227
+ - [ruff-lint](https://docs.astral.sh/ruff/): Fix by ruff for lint.
228
+ - [ruff-format-diff](https://docs.astral.sh/ruff/): Just show ruff format result.
229
+ - [ruff-format](https://docs.astral.sh/ruff/): Format by ruff.
198
230
  - For Shell script
199
231
  - [shellcheck](https://www.shellcheck.net/): ShellCheck - A shell script static analysis tool
200
232
  - For Markdown
@@ -233,5 +265,10 @@ Example options can be made by `ppc` command:
233
265
  $ ppc --pyproject >> pyproject.toml
234
266
  ```
235
267
 
236
- You may want to modify after adding these configurations.
268
+ or
237
269
 
270
+ ```
271
+ $ ppc --pyproject --ruff >> pyproject.toml
272
+ ```
273
+
274
+ You may want to modify after adding these configurations.
@@ -0,0 +1,9 @@
1
+ pyproject_pre_commit/__init__.py,sha256=rUeC_hXVqI0tVQ-QyGHvz0r9qkZHCG2D0Mql5Wu5udc,111
2
+ pyproject_pre_commit/__version__.py,sha256=IHT4mKrIr8eV-C3HtmIVD85iGVH25n2ohoff31kaJ1A,93
3
+ pyproject_pre_commit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ pyproject_pre_commit/pyproject_pre_commit.py,sha256=AeMBDaJrcSyEVxB3g5V5d79ZvN_7zhyeEpr5mWP6Oyw,3962
5
+ pyproject_pre_commit-0.3.1.dist-info/METADATA,sha256=WoJYpjFcvTEw7hFyfh7duSaDS1AUocmNegvS-tKIrqg,9435
6
+ pyproject_pre_commit-0.3.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
7
+ pyproject_pre_commit-0.3.1.dist-info/entry_points.txt,sha256=SWEvPSMZ57o6ihwt-tVBkwQzvuq1Zk_Re4RJWtvM5Rw,50
8
+ pyproject_pre_commit-0.3.1.dist-info/licenses/LICENSE,sha256=KPHimGp4ehdaHn7s0RrnWAqKefaRTu5b_zUz7cGVuo8,11337
9
+ pyproject_pre_commit-0.3.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: hatchling 1.25.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ppc = pyproject_pre_commit:main
@@ -1,9 +0,0 @@
1
- pyproject_pre_commit/__init__.py,sha256=rUeC_hXVqI0tVQ-QyGHvz0r9qkZHCG2D0Mql5Wu5udc,111
2
- pyproject_pre_commit/__version__.py,sha256=IHT4mKrIr8eV-C3HtmIVD85iGVH25n2ohoff31kaJ1A,93
3
- pyproject_pre_commit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- pyproject_pre_commit/pyproject_pre_commit.py,sha256=QkkNiKdmRnZrY41uFgCQTLGCICeuCE9_pPbkYNnS2rA,1783
5
- pyproject_pre_commit-0.2.5.dist-info/LICENSE,sha256=KPHimGp4ehdaHn7s0RrnWAqKefaRTu5b_zUz7cGVuo8,11337
6
- pyproject_pre_commit-0.2.5.dist-info/METADATA,sha256=aYUQKKu__-8MeetzZhc3yM2wN3vm60zSsZJY3_2phaM,8955
7
- pyproject_pre_commit-0.2.5.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
8
- pyproject_pre_commit-0.2.5.dist-info/entry_points.txt,sha256=WQsPu5pqy5JVtCv-HsGY_1dzPyCrugD9_7PicX_t8c0,49
9
- pyproject_pre_commit-0.2.5.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- ppc=pyproject_pre_commit:main
3
-