Skip to content

Commit 9a9e3c2

Browse files
committed
Rename _HookRelay -> HookRelay, export it as pluggy.HookRelay
For typing purposes, refs #428. The old name `pluggy._hooks._HookRelay` is kept for backward compatibility, no reason to break the "offenders" who have imported it before.
1 parent 1b5fd51 commit 9a9e3c2

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

docs/api_reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ API Reference
2626
:show-inheritance:
2727
:members:
2828

29-
.. autoclass:: pluggy._hooks._HookRelay()
29+
.. autoclass:: pluggy.HookRelay()
3030
:members:
3131

3232
.. data:: <hook name>

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,8 @@ a :py:class:`pluggy.HookCaller` which in turn *loops* through the
743743
``1:N`` registered *hookimpls* and calls them in sequence.
744744

745745
Every :py:class:`~pluggy.PluginManager` has a ``hook`` attribute
746-
which is an instance of this :py:class:`pluggy._hooks._HookRelay`.
747-
The :py:class:`~pluggy._hooks._HookRelay` itself contains references
746+
which is an instance of :py:class:`pluggy.HookRelay`.
747+
The :py:class:`~pluggy.HookRelay` itself contains references
748748
(by hook name) to each registered *hookimpl*'s :py:class:`~pluggy.HookCaller` instance.
749749

750750
More practically you call a *hook* like so:

src/pluggy/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
"PluginValidationError",
1111
"HookCaller",
1212
"HookCallError",
13+
"HookRelay",
1314
"HookspecMarker",
1415
"HookimplMarker",
1516
"Result",
1617
]
1718

1819
from ._manager import PluginManager, PluginValidationError
1920
from ._result import HookCallError, Result
20-
from ._hooks import HookspecMarker, HookimplMarker, HookCaller
21+
from ._hooks import HookspecMarker, HookimplMarker, HookCaller, HookRelay

src/pluggy/_hooks.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def varnames(func: object) -> tuple[tuple[str, ...], tuple[str, ...]]:
341341
return args, kwargs
342342

343343

344-
class _HookRelay:
344+
class HookRelay:
345345
"""Hook holder object for performing 1:N hook calls where N is the number
346346
of registered plugins."""
347347

@@ -356,6 +356,10 @@ def __getattr__(self, name: str) -> HookCaller:
356356
...
357357

358358

359+
# Historical name (pluggy<=1.2), kept for backward compatibility.
360+
_HookRelay = HookRelay
361+
362+
359363
_CallHistory = List[Tuple[Mapping[str, object], Optional[Callable[[Any], None]]]]
360364

361365

src/pluggy/_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
from ._callers import _multicall
1717
from ._hooks import _HookImplFunction
1818
from ._hooks import _HookImplOpts
19-
from ._hooks import _HookRelay
2019
from ._hooks import _HookSpecOpts
2120
from ._hooks import _Namespace
2221
from ._hooks import _Plugin
2322
from ._hooks import _SubsetHookCaller
2423
from ._hooks import HookCaller
2524
from ._hooks import HookImpl
25+
from ._hooks import HookRelay
2626
from ._hooks import HookSpec
2727
from ._hooks import normalize_hookimpl_opts
2828
from ._result import Result
@@ -97,7 +97,7 @@ def __init__(self, project_name: str) -> None:
9797
self._plugin_distinfo: Final[list[tuple[_Plugin, DistFacade]]] = []
9898
#: The "hook relay", used to call a hook on all registered plugins.
9999
#: See :ref:`calling`.
100-
self.hook: Final[_HookRelay] = _HookRelay()
100+
self.hook: Final[HookRelay] = HookRelay()
101101
#: The tracing entry point. See :ref:`tracing`.
102102
self.trace: Final[_tracing.TagTracerSub] = _tracing.TagTracer().get(
103103
"pluginmanage"

0 commit comments

Comments
 (0)