diff --git a/src/sp_repo_review/checks/general.py b/src/sp_repo_review/checks/general.py index 08e12058..7a23696c 100644 --- a/src/sp_repo_review/checks/general.py +++ b/src/sp_repo_review/checks/general.py @@ -123,6 +123,9 @@ def check(root: Traversable) -> bool: return root.joinpath(".pre-commit-config.yaml").is_file() +PY007_VALID_RUNNER_CONFS = frozenset(["noxfile.py", "tox.ini", "tox.toml", "pixi.toml"]) + + class PY007(General): "Supports an easy task runner (nox, tox, pixi, etc.)" @@ -131,15 +134,11 @@ class PY007(General): @staticmethod def check(root: Traversable, pyproject: dict[str, Any]) -> bool: """ - Projects must have a `noxfile.py`, `tox.ini`, or + Projects must have a `noxfile.py`, `tox.ini`, `tox.toml`, `pixi.toml` or `tool.hatch.envs`/`tool.spin`/`tool.tox` in `pyproject.toml` to encourage new contributors. """ - if root.joinpath("noxfile.py").is_file(): - return True - if root.joinpath("tox.ini").is_file(): - return True - if root.joinpath("pixi.toml").is_file(): + if any(root.joinpath(fn).is_file() for fn in PY007_VALID_RUNNER_CONFS): return True match pyproject.get("tool", {}): case {"hatch": {"envs": object()}}: diff --git a/tests/test_general.py b/tests/test_general.py index ec67b645..634c0f4f 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -4,6 +4,7 @@ from repo_review.testing import compute_check from sp_repo_review._compat import tomllib +from sp_repo_review.checks.general import PY007_VALID_RUNNER_CONFS def test_py001(tmp_path: Path): @@ -140,7 +141,7 @@ def test_py006_missing(tmp_path: Path): assert not compute_check("PY006", root=simple).result -@pytest.mark.parametrize("runnerfile", ["noxfile.py", "tox.ini", "pixi.toml"]) +@pytest.mark.parametrize("runnerfile", sorted(PY007_VALID_RUNNER_CONFS)) def test_py007(tmp_path: Path, runnerfile: str): simple = tmp_path / "simple" simple.mkdir()