From 18ab1b19262582f8fdc09aee443a5b2ba1bca05a Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Mon, 17 Jun 2024 22:16:48 +0200 Subject: [PATCH] add the extra sphinx annotations to refer to Path instances --- doc/en/conf.py | 5 +++-- src/_pytest/hookspec.py | 6 ++++++ src/_pytest/main.py | 2 +- tox.ini | 6 +++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/en/conf.py b/doc/en/conf.py index eb00f2bcaf1..ec26340c453 100644 --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -21,9 +21,11 @@ from textwrap import dedent from typing import TYPE_CHECKING -from _pytest import __version__ as version +from _pytest import __version__ as full_version +version = full_version.split("+")[0] + if TYPE_CHECKING: import sphinx.application @@ -169,7 +171,6 @@ nitpick_ignore = [ # TODO (fix in pluggy?) ("py:class", "HookCaller"), - ("py:class", "Path"), # figure how to map to interpshinx ("py:class", "HookspecMarker"), ("py:exc", "PluginValidationError"), # Might want to expose/TODO (https://github.com/pytest-dev/pytest/issues/7469) diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 13f4fddbddb..99614899994 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -321,6 +321,7 @@ def pytest_ignore_collect( Stops at first non-None result, see :ref:`firstresult`. :param collection_path: The path to analyze. + :type collection_path: pathlib.Path :param path: The path to analyze (deprecated). :param config: The pytest config object. @@ -354,6 +355,7 @@ def pytest_collect_directory(path: Path, parent: Collector) -> Collector | None: Stops at first non-None result, see :ref:`firstresult`. :param path: The path to analyze. + :type path: pathlib.Path See :ref:`custom directory collectors` for a simple example of use of this hook. @@ -386,6 +388,7 @@ def pytest_collect_file( The new node needs to have the specified ``parent`` as a parent. :param file_path: The path to analyze. + :type file_path: pathlib.Path :param path: The path to collect (deprecated). .. versionchanged:: 7.0.0 @@ -507,6 +510,7 @@ def pytest_pycollect_makemodule( Stops at first non-None result, see :ref:`firstresult`. :param module_path: The path of the module to collect. + :type module_path: pathlib.Path :param path: The path of the module to collect (deprecated). .. versionchanged:: 7.0.0 @@ -1026,6 +1030,7 @@ def pytest_report_header( # type:ignore[empty-body] :param config: The pytest config object. :param start_path: The starting dir. + :type start_path: pathlib.Path :param startdir: The starting dir (deprecated). .. note:: @@ -1069,6 +1074,7 @@ def pytest_report_collectionfinish( # type:ignore[empty-body] :param config: The pytest config object. :param start_path: The starting dir. + :type start_path: pathlib.Path :param startdir: The starting dir (deprecated). :param items: List of pytest items that are going to be executed; this list should not be modified. diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 5ab5cdeccfd..47ebad4713d 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -510,7 +510,7 @@ def from_parent( # type: ignore[override] :param parent: The parent collector of this Dir. :param path: The directory's path. - :type path: :ref:`python:pathlib.Path` + :type path: pathlib.Path """ return super().from_parent(parent=parent, path=path) diff --git a/tox.ini b/tox.ini index 35b335a015d..7d9171467c7 100644 --- a/tox.ini +++ b/tox.ini @@ -92,7 +92,11 @@ commands = # the '-t changelog_towncrier_draft' tags makes sphinx include the draft # changelog in the docs; this does not happen on ReadTheDocs because it uses # the standard sphinx command so the 'changelog_towncrier_draft' is never set there - sphinx-build -W --keep-going -b html doc/en doc/en/_build/html -t changelog_towncrier_draft {posargs:} + sphinx-build \ + -j auto \ + -W --keep-going \ + -b html doc/en doc/en/_build/html \ + -t changelog_towncrier_draft {posargs:} setenv = # Sphinx is not clean of this warning. PYTHONWARNDEFAULTENCODING=