From 9ad8b9fc36f4f62e085b1ad9a8b8bdf041cd8fa9 Mon Sep 17 00:00:00 2001
From: Ran Benita <ran@unusedvar.com>
Date: Sun, 9 Jan 2022 23:17:48 +0200
Subject: [PATCH 1/3] hookspec: remove explicit `:param` types

Duplicates info in the type annotations which sphinx understands.
---
 src/_pytest/hookspec.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py
index c1963b4d7..a5c9aff70 100644
--- a/src/_pytest/hookspec.py
+++ b/src/_pytest/hookspec.py
@@ -54,7 +54,7 @@ def pytest_addhooks(pluginmanager: "PytestPluginManager") -> None:
     """Called at plugin registration time to allow adding new hooks via a call to
     :func:`pluginmanager.add_hookspecs(module_or_class, prefix) <pytest.PytestPluginManager.add_hookspecs>`.
 
-    :param pytest.PytestPluginManager pluginmanager: The pytest plugin manager.
+    :param pluginmanager: The pytest plugin manager.
 
     .. note::
         This hook is incompatible with hook wrappers.
@@ -68,7 +68,7 @@ def pytest_plugin_registered(
     """A new pytest plugin got registered.
 
     :param plugin: The plugin module or instance.
-    :param pytest.PytestPluginManager manager: pytest plugin manager.
+    :param manager: pytest plugin manager.
 
     .. note::
         This hook is incompatible with hook wrappers.
@@ -86,13 +86,13 @@ def pytest_addoption(parser: "Parser", pluginmanager: "PytestPluginManager") ->
         files situated at the tests root directory due to how pytest
         :ref:`discovers plugins during startup <pluginorder>`.
 
-    :param pytest.Parser parser:
+    :param parser:
         To add command line options, call
         :py:func:`parser.addoption(...) <pytest.Parser.addoption>`.
         To add ini-file values call :py:func:`parser.addini(...)
         <pytest.Parser.addini>`.
 
-    :param pytest.PytestPluginManager pluginmanager:
+    :param pluginmanager:
         The pytest plugin manager, which can be used to install :py:func:`~pytest.hookspec`'s
         or :py:func:`~pytest.hookimpl`'s and allow one plugin to call another plugin's hooks
         to change how command line options are added.
@@ -127,7 +127,7 @@ def pytest_configure(config: "Config") -> None:
     .. note::
         This hook is incompatible with hook wrappers.
 
-    :param pytest.Config config: The pytest config object.
+    :param config: The pytest config object.
     """
 
 
@@ -435,7 +435,7 @@ def pytest_make_parametrize_id(
 
     :param config: The pytest config object.
     :param val: The parametrized value.
-    :param str argname: The automatic parameter name produced by pytest.
+    :param argname: The automatic parameter name produced by pytest.
     """
 
 

From dd1447cfe509fac989258e078a73609e0d122a73 Mon Sep 17 00:00:00 2001
From: Ran Benita <ran@unusedvar.com>
Date: Mon, 10 Jan 2022 00:04:20 +0200
Subject: [PATCH 2/3] hookspec: move pytest_load_initial_conftests up

Reflect the order in which the plugins are called.
---
 src/_pytest/hookspec.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py
index a5c9aff70..f0c579c7b 100644
--- a/src/_pytest/hookspec.py
+++ b/src/_pytest/hookspec.py
@@ -156,18 +156,6 @@ def pytest_cmdline_parse(
     """
 
 
-@hookspec(firstresult=True)
-def pytest_cmdline_main(config: "Config") -> Optional[Union["ExitCode", int]]:
-    """Called for performing the main command line action. The default
-    implementation will invoke the configure hooks and runtest_mainloop.
-
-    Stops at first non-None result, see :ref:`firstresult`.
-
-    :param config: The pytest config object.
-    :returns: The exit code.
-    """
-
-
 def pytest_load_initial_conftests(
     early_config: "Config", parser: "Parser", args: List[str]
 ) -> None:
@@ -183,6 +171,18 @@ def pytest_load_initial_conftests(
     """
 
 
+@hookspec(firstresult=True)
+def pytest_cmdline_main(config: "Config") -> Optional[Union["ExitCode", int]]:
+    """Called for performing the main command line action. The default
+    implementation will invoke the configure hooks and runtest_mainloop.
+
+    Stops at first non-None result, see :ref:`firstresult`.
+
+    :param config: The pytest config object.
+    :returns: The exit code.
+    """
+
+
 # -------------------------------------------------------------------------
 # collection hooks
 # -------------------------------------------------------------------------

From c973ccb622da11181bbb820fa5861e825982f271 Mon Sep 17 00:00:00 2001
From: Ran Benita <ran@unusedvar.com>
Date: Mon, 15 Jan 2024 23:46:59 +0200
Subject: [PATCH 3/3] hookspec: modernize a reference

---
 src/_pytest/hookspec.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py
index f0c579c7b..404eb4e96 100644
--- a/src/_pytest/hookspec.py
+++ b/src/_pytest/hookspec.py
@@ -173,8 +173,10 @@ def pytest_load_initial_conftests(
 
 @hookspec(firstresult=True)
 def pytest_cmdline_main(config: "Config") -> Optional[Union["ExitCode", int]]:
-    """Called for performing the main command line action. The default
-    implementation will invoke the configure hooks and runtest_mainloop.
+    """Called for performing the main command line action.
+
+    The default implementation will invoke the configure hooks and
+    :hook:`pytest_runtestloop`.
 
     Stops at first non-None result, see :ref:`firstresult`.