diff --git a/.github/workflows/reusable-rr-tests.yml b/.github/workflows/reusable-rr-tests.yml index c5e81efa..4b64cea3 100644 --- a/.github/workflows/reusable-rr-tests.yml +++ b/.github/workflows/reusable-rr-tests.yml @@ -28,7 +28,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install package - run: python -m pip install .[test,cli] + run: python -m pip install .[tests,cli] - name: Test package run: python -m pytest -ra diff --git a/README.md b/README.md index ca5bb47c..0de55809 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ backports structure with a small typing example. - An pylint nox target can be used to run pylint, which integrated GHA annotations - A ReadTheDocs-ready Sphinx docs folder and `[docs]` extra -- A test folder and pytest `[test]` extra +- A test folder and pytest `[tests]` extra - A noxfile is included with a few common targets Setuptools only: 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/gha_basic.md b/docs/pages/guides/gha_basic.md index de7b49e1..d6a9f31f 100644 --- a/docs/pages/guides/gha_basic.md +++ b/docs/pages/guides/gha_basic.md @@ -115,7 +115,7 @@ tests: allow-prereleases: true - name: Install package - run: python -m pip install -e .[test] + run: python -m pip install -e .[tests] - name: Test package run: python -m pytest diff --git a/docs/pages/guides/gha_wheels.md b/docs/pages/guides/gha_wheels.md index 7f8e2fbc..e187c738 100644 --- a/docs/pages/guides/gha_wheels.md +++ b/docs/pages/guides/gha_wheels.md @@ -62,9 +62,9 @@ test-command = "pytest {project}/tests" build-verbosity = 1 ``` -The `test-extras` will cause the pip install to use `[test]`. The `test-command` -will use pytest to run your tests. You can also set the build verbosity (`-v` in -pip) if you want to. +The `test-extras` will cause the pip install to use `[tests]`. The +`test-command` will use pytest to run your tests. You can also set the build +verbosity (`-v` in pip) if you want to. ## Making an SDist 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/docs/pages/guides/tasks.md b/docs/pages/guides/tasks.md index 742f79d2..94ad05aa 100644 --- a/docs/pages/guides/tasks.md +++ b/docs/pages/guides/tasks.md @@ -105,7 +105,7 @@ def tests(session: nox.Session) -> None: """ Run the unit and regular tests. """ - session.install(".[test]") + session.install(".[tests]") session.run("pytest", *session.posargs) ``` @@ -212,7 +212,7 @@ def tests(session: nox.Session) -> None: """ Run the unit and regular tests. """ - session.install(".[test]") + session.install(".[tests]") session.run("pytest", *session.posargs) ``` diff --git a/noxfile.py b/noxfile.py index be943dde..17f9b14d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -224,7 +224,7 @@ def tests(session: nox.Session, backend: str, vcs: bool) -> None: session.chdir(cookie) name = f"cookie-{backend}" - session.install(".[test]") + session.install(".[tests]") session.run("python", "-m", "pytest", "-ra") version = session.run( "python", 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..3f6957b4 100644 --- a/src/sp_repo_review/checks/pyproject.py +++ b/src/sp_repo_review/checks/pyproject.py @@ -241,5 +241,65 @@ 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 | None: + """ + + Tests target should be `tests` not `test` + + ```toml + [project.optional-dependencies] + tests = [ + 'pytest', + ... + ] + ``` + """ + if "tool" not in pyproject: + return None + if "project.optional-dependencies" not in pyproject["tool"]: + return None + 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 | None: + """ + + docs target should be `docs` not `doc` + + ```toml + [project.optional-dependencies] + docs = [ + 'sphinx', + ... + ] + ``` + """ + if "tool" not in pyproject: + return None + if "project.optional-dependencies" not in pyproject["tool"]: + return None + optional_deps = pyproject["tool"]["project.optional-dependencies"] + if "docs" in optional_deps: + return True + return "doc" not in optional_deps + + def repo_review_checks() -> dict[str, PyProject]: return {p.__name__: p() for p in PyProject.__subclasses__()} diff --git a/{{cookiecutter.project_name}}/noxfile.py b/{{cookiecutter.project_name}}/noxfile.py index b80f757f..176e9b81 100644 --- a/{{cookiecutter.project_name}}/noxfile.py +++ b/{{cookiecutter.project_name}}/noxfile.py @@ -40,7 +40,7 @@ def tests(session: nox.Session) -> None: """ Run the unit and regular tests. """ - session.install(".[test]") + session.install(".[tests]") session.run("pytest", *session.posargs) 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.__ci=='gitlab' %}.gitlab-ci.yml{% endif %} b/{{cookiecutter.project_name}}/{% if cookiecutter.__ci=='gitlab' %}.gitlab-ci.yml{% endif %} index 7d05d089..2b1ef87c 100644 --- a/{{cookiecutter.project_name}}/{% if cookiecutter.__ci=='gitlab' %}.gitlab-ci.yml{% endif %} +++ b/{{cookiecutter.project_name}}/{% if cookiecutter.__ci=='gitlab' %}.gitlab-ci.yml{% endif %} @@ -75,7 +75,7 @@ tests: - if: $CI_PIPELINE_SOURCE == "push" script: - python -V - - python -m pip install .[test] + - python -m pip install .[tests] - python -m pytest -ra --cov={{ cookiecutter.project_name }} parallel: matrix: 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