Skip to content

Commit 1986e9b

Browse files
committed
enh: cleanup and organization pyproject.toml
1 parent 9ba23ab commit 1986e9b

File tree

1 file changed

+61
-49
lines changed

1 file changed

+61
-49
lines changed

template/pyproject.toml.jinja

Lines changed: 61 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -217,42 +217,46 @@ exclude = "_version.py"
217217
# Hatch Environments
218218
################################################################################
219219

220-
{%- if use_lint %}
221-
[tool.hatch.envs.style]
222-
description = """Check the style of the codebase."""
220+
#--------------- Build and check your package ---------------#
221+
222+
# This table installs the tools you need to test and build your package
223+
[tool.hatch.envs.install]
224+
description = """Test the installation the package."""
223225
dependencies = [
224-
"pydoclint",
225-
"ruff",
226+
"pip",
227+
"twine",
226228
]
227229
detached = true
228230

229-
[tool.hatch.envs.style.scripts]
230-
docstrings = "pydoclint src/ tests/"
231-
code = "ruff check {args}"
232-
format = "ruff format {args}"
233-
check = ["docstrings", "code"]
234-
{%- endif %}
235-
236-
[tool.hatch.envs.audit]
237-
description = """Check dependencies for security vulnerabilities."""
238-
extra-dependencies = [
239-
"pip-audit",
231+
# This table installs created the command hatch run install:check which will build and check your package.
232+
[tool.hatch.envs.install.scripts]
233+
check = [
234+
"pip check",
235+
"hatch build {args:--clean}",
236+
"twine check dist/*",
240237
]
241238

242-
[tool.hatch.envs.audit.scripts]
243-
check = ["pip-audit"]
239+
#--------------- Run tests ---------------#
244240

245-
{%- if use_types %}
246-
[tool.hatch.envs.types]
247-
description = """Check the static types of the codebase."""
248-
dependencies = [
249-
"mypy",
241+
{% if use_test %}
242+
[tool.hatch.envs.test]
243+
description = """Run the test suite."""
244+
extra-dependencies = [
245+
"pytest",
246+
"pytest-cov",
247+
"pytest-raises",
248+
"pytest-randomly",
249+
"pytest-xdist",
250250
]
251251

252-
[tool.hatch.envs.types.scripts]
253-
check = "mypy src/{{ package_name }}"
252+
[[tool.hatch.envs.test.matrix]]
253+
python = ["3.10", "3.11", "3.12", "3.13"]
254+
255+
[tool.hatch.envs.test.scripts]
256+
run = "pytest {args:--cov={{ package_name }} --cov-report=term-missing}"
254257
{%- endif %}
255258

259+
#--------------- Build and preview your documentation ---------------#
256260
{% if documentation != "no" %}
257261
# This sets up a hatch environment with associated dependencies that need to be installed
258262
[tool.hatch.envs.docs]
@@ -287,38 +291,46 @@ serve = ["sphinx-apidoc -o docs/api src/{{ package_name}}", "sphinx-autobuild do
287291
{%- endif %}
288292
{%- endif %}
289293

290-
# This table installs teh tools you need to test and build your package
291-
[tool.hatch.envs.install]
292-
description = """Test the installation the package."""
294+
{%- if use_lint %}
295+
#--------------- Format & style your code ---------------#
296+
297+
[tool.hatch.envs.style]
298+
description = """Check the style of the codebase."""
293299
dependencies = [
294-
"pip",
295-
"twine",
300+
"pydoclint",
301+
"ruff",
296302
]
297303
detached = true
298304

299-
# This table installs created the command hatch run install:check which will build and check your package.
300-
[tool.hatch.envs.install.scripts]
301-
check = [
302-
"pip check",
303-
"hatch build {args:--clean}",
304-
"twine check dist/*",
305-
]
305+
[tool.hatch.envs.style.scripts]
306+
docstrings = "pydoclint src/ tests/"
307+
code = "ruff check {args}"
308+
format = "ruff format {args}"
309+
check = ["docstrings", "code"]
310+
{%- endif %}
306311

307-
{%- if use_test %}
308-
[tool.hatch.envs.test]
309-
description = """Run the test suite."""
312+
#--------------- Check security for your dependencies ---------------#
313+
314+
[tool.hatch.envs.audit]
315+
description = """Check dependencies for security vulnerabilities."""
310316
extra-dependencies = [
311-
"pytest",
312-
"pytest-cov",
313-
"pytest-raises",
314-
"pytest-randomly",
315-
"pytest-xdist",
317+
"pip-audit",
316318
]
317319

318-
[[tool.hatch.envs.test.matrix]]
319-
python = ["3.10", "3.11", "3.12", "3.13"]
320+
[tool.hatch.envs.audit.scripts]
321+
check = ["pip-audit"]
320322

321-
[tool.hatch.envs.test.scripts]
322-
run = "pytest {args:--cov={{ package_name }} --cov-report=term-missing}"
323+
#--------------- Typing ---------------#
324+
325+
{%- if use_types %}
326+
[tool.hatch.envs.types]
327+
description = """Check the static types of the codebase."""
328+
dependencies = [
329+
"mypy",
330+
]
331+
332+
[tool.hatch.envs.types.scripts]
333+
check = "mypy src/{{ package_name }}"
323334
{%- endif %}
335+
324336
{%- endif %}

0 commit comments

Comments
 (0)