Skip to content

Commit 84c9489

Browse files
committed
Update packaing guide and repo-review to match spec13
See scientific-python/specs#324
1 parent 8dec1ed commit 84c9489

File tree

7 files changed

+84
-9
lines changed

7 files changed

+84
-9
lines changed

docs/_includes/pyproject.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Here is an example of a simple extras:
5858

5959
```toml
6060
[project.optional-dependencies]
61-
test = [
61+
tests = [
6262
"pytest >=6.0",
6363
]
6464
mpl = [

docs/pages/guides/packaging_classic.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ called `package`:
376376

377377
```ini
378378
[options.extras_require]
379-
test =
379+
tests =
380380
pytest >=6.0
381381
mpl =
382382
matplotlib >=2.0

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies = [
3939
cli = [
4040
"repo-review[cli]",
4141
]
42-
test = [
42+
tests = [
4343
"pytest >=7",
4444
"repo-review >=0.10.6",
4545
]

src/sp_repo_review/checks/general.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,23 @@ class PY004(General):
6464

6565
@staticmethod
6666
def check(package: Traversable) -> bool:
67-
"Projects must have documentation in a folder called docs (disable if not applicable)"
67+
"Projects must have documentation in a folder called doc or docs (disable if not applicable)"
6868
return len([p for p in package.iterdir() if "doc" in p.name]) > 0
6969

7070

71+
class PY004b(General):
72+
"Documentation folder should be `docs` not `doc`"
73+
74+
requires = {"PY004"}
75+
76+
url = mk_url("packaging-simple")
77+
78+
@staticmethod
79+
def check(package: Traversable) -> bool:
80+
"Projects must have documentation in a folder called `docs` not `doc`"
81+
return any(p.name == "docs" for p in package.iterdir())
82+
83+
7184
class PY005(General):
7285
"Has tests folder"
7386

src/sp_repo_review/checks/pyproject.py

+62
Original file line numberDiff line numberDiff line change
@@ -241,5 +241,67 @@ def check(pyproject: dict[str, Any]) -> bool:
241241
return "filterwarnings" in options
242242

243243

244+
class PP310(PyProject):
245+
"Tests target is test not test (spec13)"
246+
247+
requires = {"PP301"}
248+
url = mk_url("pytest")
249+
250+
@staticmethod
251+
def check(pyproject: dict[str, Any]) -> bool:
252+
"""
253+
254+
Tests target should be `tests` not `test`
255+
256+
```toml
257+
[project.optional-dependencies]
258+
tests = [
259+
'pytest',
260+
...
261+
]
262+
```
263+
"""
264+
if "tool" not in pyproject:
265+
return True
266+
if "project.optional-dependencies" not in pyproject["tool"]:
267+
return True
268+
optional_deps = pyproject["tool"]["project.optional-dependencies"]
269+
if "tests" in optional_deps:
270+
return True
271+
return "test" not in optional_deps
272+
273+
274+
class PP311(PyProject):
275+
"Tests target is `docs not` `doc` (spec13)"
276+
277+
requires = {"PP301"}
278+
url = mk_url("pytest")
279+
280+
@staticmethod
281+
def check(pyproject: dict[str, Any]) -> bool:
282+
"""
283+
284+
docs target should be `docs` not `doc`
285+
286+
```toml
287+
[project.optional-dependencies]
288+
docs = [
289+
'sphinx',
290+
...
291+
]
292+
```
293+
"""
294+
if "tool" not in pyproject:
295+
return True
296+
if "project.optional-dependencies" not in pyproject["tool"]:
297+
return True
298+
optional_deps = pyproject["tool"]["project.optional-dependencies"]
299+
if "docs" in optional_deps:
300+
return True
301+
return "doc" not in optional_deps
302+
303+
return True # it's ok to have None
304+
305+
244306
def repo_review_checks() -> dict[str, PyProject]:
245307
return {p.__name__: p() for p in PyProject.__subclasses__()}

{{cookiecutter.project_name}}/pyproject.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pytest = ">= 6"
129129
pytest-cov = ">= 3"
130130

131131
[tool.poetry.extras]
132-
test = ["pytest", "pytest-cov"]
132+
tests = ["pytest", "pytest-cov"]
133133
dev = ["pytest", "pytest-cov"]
134134
docs = [
135135
"furo",
@@ -195,7 +195,7 @@ dynamic = ["version"]
195195
dependencies = []
196196

197197
[project.optional-dependencies]
198-
test = [
198+
tests = [
199199
"pytest >=6",
200200
"pytest-cov >=3",
201201
]
@@ -259,7 +259,7 @@ build.hooks.vcs.version-file = "src/{{ cookiecutter.__project_slug }}/_version.p
259259

260260
[tool.hatch.envs.default]
261261
features = ["test"]
262-
scripts.test = "pytest {args}"
262+
scripts.tests = "pytest {args}"
263263

264264

265265
{%- elif cookiecutter.backend == "pdm" %}
@@ -281,7 +281,7 @@ path = "src/{{ cookiecutter.__project_slug }}/__init__.py"
281281
{%- endif %}
282282

283283
[tool.pdm.dev-dependencies]
284-
devtest = ["pytest", "pytest-cov"]
284+
devtests = ["pytest", "pytest-cov"]
285285

286286
{%- endif %}
287287

{{cookiecutter.project_name}}/{% if cookiecutter.backend in ['setuptools','pybind11'] %}setup.cfg{% endif %}

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ docs =
7373
sphinx>=7.0
7474
sphinx-autodoc-typehints
7575
sphinx-copybutton
76-
test =
76+
tests =
7777
pytest>=6
7878
pytest-cov>=3

0 commit comments

Comments
 (0)