Skip to content

Commit 5ce9caf

Browse files
OCoppingcallumforrester
authored andcommitted
Improvements to template pyproject.toml
1 parent 7ff792c commit 5ce9caf

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

template/pyproject.toml.jinja

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,22 @@ requires-python = ">=3.11"
2020

2121
[project.optional-dependencies]
2222
dev = [
23+
"build",
2324
"copier",
2425
{% if type_checker=="mypy" %}"mypy",
2526
{% endif %}{% if sphinx %}"myst-parser",
2627
{% endif %}"pipdeptree",
2728
"pre-commit",
2829
{% if sphinx %}"pydata-sphinx-theme>=0.12",
29-
{% endif %} {% if type_checker=="pyright" %}"pyright",
30+
{% endif %}{% if type_checker=="pyright" %}"pyright",
3031
{% endif %}"pytest>8.3.4",
3132
"pytest-cov",
3233
"ruff",
3334
{% if sphinx %}"sphinx-autobuild",
3435
"sphinx-copybutton",
3536
"sphinx-design",
3637
{% endif %}"tox-uv",
38+
"twine",
3739
"types-mock",
3840
]
3941

@@ -79,55 +81,73 @@ source = ["src", "**/site-packages/"]
7981

8082
[tool.tox]
8183
skipsdist = true
84+
requires = ["tox-uv>=1.25.0"]
85+
# envs to runs automatically with tox -p
86+
env_list = ["pre-commit", "type-checking", "docs"] # "tests"]
87+
88+
[tool.tox.env]
89+
passenv = { "*" = "" }
90+
# Include setuptools, pip, ... in the tox envs
91+
uv_seed = { enabled = true }
8292

8393
[tool.tox.env.pre-commit]
8494
description = "Run pre-commit"
85-
direct = true
8695
allowlist_externals = ["pre-commit"]
8796
commands = [
8897
[
8998
"pre-commit",
9099
"run",
91100
#"--all-files",
92101
"--show-diff-on-failure",
93-
"{posargs}",
102+
{ replace = "posargs", default = [], extend = true },
94103
],
95104
]
96105

97106
[tool.tox.env.type-checking]
98107
description = "Run type-checking"
99-
direct = true
100108
allowlist_externals = ["{{ type_checker }}"]
101-
commands = [["{{ type_checker }}", "src", "{posargs}"]]
109+
# needed otherwise throws reportUnknownMemberType errors
110+
deps = ["pytest"]
111+
commands = [
112+
[
113+
"{{ type_checker }}",
114+
"src",
115+
"tests",
116+
{ replace = "posargs", default = [
117+
], extend = true },
118+
],
119+
]
102120

103121
[tool.tox.env.tests]
104122
description = "Run tests"
105-
direct = true
106123
allowlist_externals = ["pytest"]
107124
commands = [
108125
[
109126
"pytest",
110-
"--cov={{ package_name}}",
127+
"-vv",
128+
"--cov={{ package_name }}",
111129
"--cov-report",
112130
"term",
113131
"--cov-report",
114132
"xml:cov.xml",
115-
"{posargs}",
133+
{ replace = "posargs", default = [
134+
], extend = true },
116135
],
117136
]
118137

119138
{% if sphinx %}[tool.tox.env.docs]
120139
description = "Run docs"
121-
direct = true
122140
allowlist_externals = ["sphinx-build", "sphinx-autobuild"]
123141
commands = [
124142
[
125-
"sphinx-{posargs:build}",
126-
"-EW",
127-
"--keep-going",
143+
"sphinx-build",
128144
"-T",
129145
"docs",
130146
"build/html",
147+
{ replace = "posargs", default = [
148+
"-EW",
149+
"--keep-going",
150+
], extend = true },
131151
],
132152
]
133153
{% endif %}

0 commit comments

Comments
 (0)