diff --git a/docs/_includes/pyproject.md b/docs/_includes/pyproject.md index e5eb6ec1..d240dc7b 100644 --- a/docs/_includes/pyproject.md +++ b/docs/_includes/pyproject.md @@ -58,7 +58,7 @@ Here is an example of a simple extras: ```toml [project.optional-dependencies] -test = [ +tests = [ "pytest >=6.0", ] mpl = [ diff --git a/docs/pages/guides/packaging_classic.md b/docs/pages/guides/packaging_classic.md index 097b1ed3..6390a1c1 100644 --- a/docs/pages/guides/packaging_classic.md +++ b/docs/pages/guides/packaging_classic.md @@ -376,7 +376,7 @@ called `package`: ```ini [options.extras_require] -test = +tests = pytest >=6.0 mpl = matplotlib >=2.0 diff --git a/pyproject.toml b/pyproject.toml index 0c34dc01..307b5ea5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ dependencies = [ cli = [ "repo-review[cli]", ] -test = [ +tests = [ "pytest >=7", "repo-review >=0.10.6", ] diff --git a/src/sp_repo_review/checks/general.py b/src/sp_repo_review/checks/general.py index 2fa8c7ce..93a67618 100644 --- a/src/sp_repo_review/checks/general.py +++ b/src/sp_repo_review/checks/general.py @@ -64,10 +64,23 @@ class PY004(General): @staticmethod def check(package: Traversable) -> bool: - "Projects must have documentation in a folder called docs (disable if not applicable)" + "Projects must have documentation in a folder called doc or docs (disable if not applicable)" return len([p for p in package.iterdir() if "doc" in p.name]) > 0 +class PY004b(General): + "Documentation folder should be `docs` not `doc`" + + requires = {"PY004"} + + url = mk_url("packaging-simple") + + @staticmethod + def check(package: Traversable) -> bool: + "Projects must have documentation in a folder called `docs` not `doc`" + return any(p.name == "docs" for p in package.iterdir()) + + class PY005(General): "Has tests folder" diff --git a/src/sp_repo_review/checks/pyproject.py b/src/sp_repo_review/checks/pyproject.py index 607ebec5..693e05cf 100644 --- a/src/sp_repo_review/checks/pyproject.py +++ b/src/sp_repo_review/checks/pyproject.py @@ -241,5 +241,67 @@ def check(pyproject: dict[str, Any]) -> bool: return "filterwarnings" in options +class PP310(PyProject): + "Tests target is test not test (spec13)" + + requires = {"PP301"} + url = mk_url("pytest") + + @staticmethod + def check(pyproject: dict[str, Any]) -> bool: + """ + + Tests target should be `tests` not `test` + + ```toml + [project.optional-dependencies] + tests = [ + 'pytest', + ... + ] + ``` + """ + if "tool" not in pyproject: + return True + if "project.optional-dependencies" not in pyproject["tool"]: + return True + optional_deps = pyproject["tool"]["project.optional-dependencies"] + if "tests" in optional_deps: + return True + return "test" not in optional_deps + + +class PP311(PyProject): + "Tests target is `docs not` `doc` (spec13)" + + requires = {"PP301"} + url = mk_url("pytest") + + @staticmethod + def check(pyproject: dict[str, Any]) -> bool: + """ + + docs target should be `docs` not `doc` + + ```toml + [project.optional-dependencies] + docs = [ + 'sphinx', + ... + ] + ``` + """ + if "tool" not in pyproject: + return True + if "project.optional-dependencies" not in pyproject["tool"]: + return True + optional_deps = pyproject["tool"]["project.optional-dependencies"] + if "docs" in optional_deps: + return True + return "doc" not in optional_deps + + return True # it's ok to have None + + def repo_review_checks() -> dict[str, PyProject]: return {p.__name__: p() for p in PyProject.__subclasses__()} diff --git a/{{cookiecutter.project_name}}/pyproject.toml b/{{cookiecutter.project_name}}/pyproject.toml index dcab34ea..5beb99da 100644 --- a/{{cookiecutter.project_name}}/pyproject.toml +++ b/{{cookiecutter.project_name}}/pyproject.toml @@ -129,7 +129,7 @@ pytest = ">= 6" pytest-cov = ">= 3" [tool.poetry.extras] -test = ["pytest", "pytest-cov"] +tests = ["pytest", "pytest-cov"] dev = ["pytest", "pytest-cov"] docs = [ "furo", @@ -195,7 +195,7 @@ dynamic = ["version"] dependencies = [] [project.optional-dependencies] -test = [ +tests = [ "pytest >=6", "pytest-cov >=3", ] @@ -259,7 +259,7 @@ build.hooks.vcs.version-file = "src/{{ cookiecutter.__project_slug }}/_version.p [tool.hatch.envs.default] features = ["test"] -scripts.test = "pytest {args}" +scripts.tests = "pytest {args}" {%- elif cookiecutter.backend == "pdm" %} @@ -281,7 +281,7 @@ path = "src/{{ cookiecutter.__project_slug }}/__init__.py" {%- endif %} [tool.pdm.dev-dependencies] -devtest = ["pytest", "pytest-cov"] +devtests = ["pytest", "pytest-cov"] {%- endif %} diff --git a/{{cookiecutter.project_name}}/{% if cookiecutter.backend in ['setuptools','pybind11'] %}setup.cfg{% endif %} b/{{cookiecutter.project_name}}/{% if cookiecutter.backend in ['setuptools','pybind11'] %}setup.cfg{% endif %} index d0022c35..bac077a7 100644 --- a/{{cookiecutter.project_name}}/{% if cookiecutter.backend in ['setuptools','pybind11'] %}setup.cfg{% endif %} +++ b/{{cookiecutter.project_name}}/{% if cookiecutter.backend in ['setuptools','pybind11'] %}setup.cfg{% endif %} @@ -73,6 +73,6 @@ docs = sphinx>=7.0 sphinx-autodoc-typehints sphinx-copybutton -test = +tests = pytest>=6 pytest-cov>=3