17
17
from typing import final
18
18
from typing import Optional
19
19
from typing import overload
20
- from typing import TYPE_CHECKING
21
20
from typing import TypedDict
22
21
from typing import TypeVar
23
22
from typing import Union
24
23
import warnings
25
24
25
+ from ._hookrelay import HookRelay
26
26
from ._result import Result
27
27
28
28
29
29
_T = TypeVar ("_T" )
30
30
_F = TypeVar ("_F" , bound = Callable [..., object ])
31
31
_Namespace = Union [ModuleType , type ]
32
32
_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 ]]
36
37
]
37
- _HookImplFunction = Callable [..., Union [_T , Generator [None , Result [_T ], None ]]]
38
+
39
+ type _HookImplFunction [T ] = Callable [..., Union [T , Generator [None , Result [T ], None ]]]
38
40
39
41
40
42
class HookspecOpts (TypedDict ):
@@ -355,21 +357,6 @@ def varnames(func: object) -> tuple[tuple[str, ...], tuple[str, ...]]:
355
357
return args , kwargs
356
358
357
359
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
-
373
360
# Historical name (pluggy<=1.2), kept for backward compatibility.
374
361
_HookRelay = HookRelay
375
362
@@ -388,6 +375,8 @@ class HookCaller:
388
375
"_call_history" ,
389
376
)
390
377
378
+
379
+ _call_history : _CallHistory | None
391
380
def __init__ (
392
381
self ,
393
382
name : str ,
@@ -407,7 +396,7 @@ def __init__(
407
396
# 5. wrappers
408
397
# 6. tryfirst wrappers
409
398
self ._hookimpls : Final [list [HookImpl ]] = []
410
- self ._call_history : _CallHistory | None = None
399
+ self ._call_history = None
411
400
# TODO: Document, or make private.
412
401
self .spec : HookSpec | None = None
413
402
if specmodule_or_class is not None :
0 commit comments