Skip to content

Commit bde6888

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

14 files changed

+89
-16
lines changed

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ 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`
65+
The `test-extras` will cause the pip install to use `[tests]`. The `test-command`
6666
will use pytest to run your tests. You can also set the build verbosity (`-v` in
6767
pip) if you want to.
6868

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

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:
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:
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__()}

0 commit comments

Comments
 (0)