Skip to content

Commit 05ea41c

Browse files
committed
feat: check for dev dependency-group
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 141396d commit 05ea41c

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ for family, grp in itertools.groupby(collected.checks.items(), key=lambda x: x[1
321321
- [`PP003`](https://learn.scientific-python.org/development/guides/packaging-classic#PP003): Does not list wheel as a build-dep
322322
- [`PP004`](https://learn.scientific-python.org/development/guides/packaging-simple#PP004): Does not upper cap Python requires
323323
- [`PP005`](https://learn.scientific-python.org/development/guides/packaging-simple#PP005): Using SPDX project.license should not use deprecated trove classifiers
324+
- [`PP006`](https://learn.scientific-python.org/development/guides/packaging-simple#PP006): The dev dependency group should be defined
324325
- [`PP301`](https://learn.scientific-python.org/development/guides/pytest#PP301): Has pytest in pyproject
325326
- [`PP302`](https://learn.scientific-python.org/development/guides/pytest#PP302): Sets a minimum pytest to at least 6
326327
- [`PP303`](https://learn.scientific-python.org/development/guides/pytest#PP303): Sets the test paths

docs/_includes/pyproject.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ forward) and they are more composable. In contrast with extras,
118118
dependency-groups are not available when installing your package via PyPI, but
119119
they are available for local installation (and can be installed separately from
120120
your package); the `dev` group is even installed, by default, when using `uv`'s
121-
high level commands like `uv run` and `uv sync`. Here is an example:
121+
high level commands like `uv run` and `uv sync`. {% rr PP0086 %} Here is an
122+
example:
122123

123124
```toml
124125
[dependency-groups]

src/sp_repo_review/checks/pyproject.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,32 @@ def check(pyproject: dict[str, Any]) -> bool | None:
120120
return None
121121

122122

123+
class PP006(PyProject):
124+
"The dev dependency group should be defined"
125+
126+
requires = {"PY001"}
127+
url = mk_url("packaging-simple")
128+
129+
@staticmethod
130+
def check(pyproject: dict[str, Any]) -> bool:
131+
"""
132+
The `dev` dependency group should be defined so tools like uv will work.
133+
These are better than the old `extras` system for tests, docs, and other
134+
dependencies that are not needed for PyPI installs.
135+
136+
```toml
137+
[dependency-groups]
138+
dev = [ {{ include-group = "test" }} ]
139+
test = [ "pytest" ]
140+
```
141+
"""
142+
match pyproject:
143+
case {"dependency-groups": {"dev": list()}}:
144+
return True
145+
case _:
146+
return False
147+
148+
123149
class PP301(PyProject):
124150
"Has pytest in pyproject"
125151

tests/test_pyproject.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,25 @@ def test_PP005_both():
182182
assert not compute_check("PP005", pyproject=toml).result
183183

184184

185+
def test_PP006_present():
186+
toml = toml_loads("""
187+
[dependency-groups]
188+
dev = [ { include-group = "test" } ]
189+
test = [ "pytest" ]
190+
""")
191+
192+
assert compute_check("PP006", pyproject=toml).result
193+
194+
195+
def test_PP006_missing():
196+
toml = toml_loads("""
197+
[dependency-groups]
198+
test = [ "pytest" ]
199+
""")
200+
201+
assert not compute_check("PP006", pyproject=toml).result
202+
203+
185204
def test_PP302_okay_intstr():
186205
toml = toml_loads("""
187206
[tool.pytest.ini_options]

0 commit comments

Comments
 (0)