1717from typing import final
1818from typing import Optional
1919from typing import overload
20- from typing import TYPE_CHECKING
2120from typing import TypedDict
2221from typing import TypeVar
2322from typing import Union
2423import warnings
2524
25+ from ._hookrelay import HookRelay
2626from ._result import Result
2727
2828
2929_T = TypeVar ("_T" )
3030_F = TypeVar ("_F" , bound = Callable [..., object ])
3131_Namespace = Union [ModuleType , type ]
3232_Plugin = object
33- _HookExec = Callable [
34- [str , Sequence ["HookImpl" ], Mapping [str , object ], bool ],
35- Union [object , list [object ]],
33+
34+ type _HookExec = Callable [
35+ [str , Sequence [HookImpl ], Mapping [str , object ], bool ],
36+ Union [object , list [object ]]
3637]
37- _HookImplFunction = Callable [..., Union [_T , Generator [None , Result [_T ], None ]]]
38+
39+ type _HookImplFunction [T ] = Callable [..., Union [T , Generator [None , Result [T ], None ]]]
3840
3941
4042class HookspecOpts (TypedDict ):
@@ -355,21 +357,6 @@ def varnames(func: object) -> tuple[tuple[str, ...], tuple[str, ...]]:
355357 return args , kwargs
356358
357359
358- @final
359- class HookRelay :
360- """Hook holder object for performing 1:N hook calls where N is the number
361- of registered plugins."""
362-
363- __slots__ = ("__dict__" ,)
364-
365- def __init__ (self ) -> None :
366- """:meta private:"""
367-
368- if TYPE_CHECKING :
369-
370- def __getattr__ (self , name : str ) -> HookCaller : ...
371-
372-
373360# Historical name (pluggy<=1.2), kept for backward compatibility.
374361_HookRelay = HookRelay
375362
@@ -388,6 +375,8 @@ class HookCaller:
388375 "_call_history" ,
389376 )
390377
378+
379+ _call_history : _CallHistory | None
391380 def __init__ (
392381 self ,
393382 name : str ,
@@ -407,7 +396,7 @@ def __init__(
407396 # 5. wrappers
408397 # 6. tryfirst wrappers
409398 self ._hookimpls : Final [list [HookImpl ]] = []
410- self ._call_history : _CallHistory | None = None
399+ self ._call_history = None
411400 # TODO: Document, or make private.
412401 self .spec : HookSpec | None = None
413402 if specmodule_or_class is not None :
0 commit comments