Skip to content

Commit f4ca3e9

Browse files
fix: allow tox.toml in rule PY007 (#739)
* ENH: allow tox.toml in rule `PY007` * Apply suggestions from code review --------- Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
1 parent ab443cc commit f4ca3e9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/sp_repo_review/checks/general.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ def check(root: Traversable) -> bool:
123123
return root.joinpath(".pre-commit-config.yaml").is_file()
124124

125125

126+
PY007_VALID_RUNNER_CONFS = frozenset(["noxfile.py", "tox.ini", "tox.toml", "pixi.toml"])
127+
128+
126129
class PY007(General):
127130
"Supports an easy task runner (nox, tox, pixi, etc.)"
128131

@@ -131,15 +134,11 @@ class PY007(General):
131134
@staticmethod
132135
def check(root: Traversable, pyproject: dict[str, Any]) -> bool:
133136
"""
134-
Projects must have a `noxfile.py`, `tox.ini`, or
137+
Projects must have a `noxfile.py`, `tox.ini`, `tox.toml`, `pixi.toml` or
135138
`tool.hatch.envs`/`tool.spin`/`tool.tox` in `pyproject.toml` to encourage new
136139
contributors.
137140
"""
138-
if root.joinpath("noxfile.py").is_file():
139-
return True
140-
if root.joinpath("tox.ini").is_file():
141-
return True
142-
if root.joinpath("pixi.toml").is_file():
141+
if any(root.joinpath(fn).is_file() for fn in PY007_VALID_RUNNER_CONFS):
143142
return True
144143
match pyproject.get("tool", {}):
145144
case {"hatch": {"envs": object()}}:

tests/test_general.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from repo_review.testing import compute_check
55

66
from sp_repo_review._compat import tomllib
7+
from sp_repo_review.checks.general import PY007_VALID_RUNNER_CONFS
78

89

910
def test_py001(tmp_path: Path):
@@ -140,7 +141,7 @@ def test_py006_missing(tmp_path: Path):
140141
assert not compute_check("PY006", root=simple).result
141142

142143

143-
@pytest.mark.parametrize("runnerfile", ["noxfile.py", "tox.ini", "pixi.toml"])
144+
@pytest.mark.parametrize("runnerfile", sorted(PY007_VALID_RUNNER_CONFS))
144145
def test_py007(tmp_path: Path, runnerfile: str):
145146
simple = tmp_path / "simple"
146147
simple.mkdir()

0 commit comments

Comments
 (0)