Skip to content

Commit 476d61d

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

15 files changed

+93
-20
lines changed

.github/workflows/reusable-rr-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
python-version: ${{ matrix.python-version }}
2929

3030
- name: Install package
31-
run: python -m pip install .[test,cli]
31+
run: python -m pip install .[tests,cli]
3232

3333
- name: Test package
3434
run: python -m pytest -ra

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ backports structure with a small typing example.
143143
- An pylint nox target can be used to run pylint, which integrated GHA
144144
annotations
145145
- A ReadTheDocs-ready Sphinx docs folder and `[docs]` extra
146-
- A test folder and pytest `[test]` extra
146+
- A test folder and pytest `[tests]` extra
147147
- A noxfile is included with a few common targets
148148

149149
Setuptools only:

docs/_includes/pyproject.md

Lines changed: 1 addition & 1 deletion
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/gha_basic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ tests:
115115
allow-prereleases: true
116116
117117
- name: Install package
118-
run: python -m pip install -e .[test]
118+
run: python -m pip install -e .[tests]
119119
120120
- name: Test package
121121
run: python -m pytest

docs/pages/guides/gha_wheels.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ test-command = "pytest {project}/tests"
6262
build-verbosity = 1
6363
```
6464

65-
The `test-extras` will cause the pip install to use `[test]`. The `test-command`
66-
will use pytest to run your tests. You can also set the build verbosity (`-v` in
67-
pip) if you want to.
65+
The `test-extras` will cause the pip install to use `[tests]`. The
66+
`test-command` will use pytest to run your tests. You can also set the build
67+
verbosity (`-v` in pip) if you want to.
6868

6969
## Making an SDist
7070

docs/pages/guides/packaging_classic.md

Lines changed: 1 addition & 1 deletion
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

docs/pages/guides/tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def tests(session: nox.Session) -> None:
105105
"""
106106
Run the unit and regular tests.
107107
"""
108-
session.install(".[test]")
108+
session.install(".[tests]")
109109
session.run("pytest", *session.posargs)
110110
```
111111

@@ -212,7 +212,7 @@ def tests(session: nox.Session) -> None:
212212
"""
213213
Run the unit and regular tests.
214214
"""
215-
session.install(".[test]")
215+
session.install(".[tests]")
216216
session.run("pytest", *session.posargs)
217217
```
218218
<!-- prettier-ignore-end -->

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def tests(session: nox.Session, backend: str, vcs: bool) -> None:
224224
session.chdir(cookie)
225225

226226
name = f"cookie-{backend}"
227-
session.install(".[test]")
227+
session.install(".[tests]")
228228
session.run("python", "-m", "pytest", "-ra")
229229
version = session.run(
230230
"python",

pyproject.toml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 14 additions & 1 deletion
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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,5 +241,65 @@ 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 | None:
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 None
266+
if "project.optional-dependencies" not in pyproject["tool"]:
267+
return None
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 | None:
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 None
296+
if "project.optional-dependencies" not in pyproject["tool"]:
297+
return None
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+
244304
def repo_review_checks() -> dict[str, PyProject]:
245305
return {p.__name__: p() for p in PyProject.__subclasses__()}

{{cookiecutter.project_name}}/noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def tests(session: nox.Session) -> None:
4040
"""
4141
Run the unit and regular tests.
4242
"""
43-
session.install(".[test]")
43+
session.install(".[tests]")
4444
session.run("pytest", *session.posargs)
4545

4646

{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 4 additions & 4 deletions
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.__ci=='gitlab' %}.gitlab-ci.yml{% endif %}

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ tests:
7575
- if: $CI_PIPELINE_SOURCE == "push"
7676
script:
7777
- python -V
78-
- python -m pip install .[test]
78+
- python -m pip install .[tests]
7979
- python -m pytest -ra --cov={{ cookiecutter.project_name }}
8080
parallel:
8181
matrix:

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

Lines changed: 1 addition & 1 deletion
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)