22Call loop machinery
33"""
44from __future__ import annotations
5+
56from ._hooks import HookImpl
67from ._result import _raise_wrapfail
78from ._result import HookCallError
89from ._result import Result
10+
911TYPE_CHECKING = False
1012if TYPE_CHECKING :
1113 from typing import cast
1719
1820 # Need to distinguish between old- and new-style hook wrappers.
1921 # Wrapping one a singleton tuple is the fastest type-safe way I found to do it.
20- Teardown = Union [
22+ Teardown = Union [
2123 Tuple [Generator [None , Result [object ], None ]],
2224 Generator [None , object , object ],
2325 ]
26+ else :
27+
28+ def cast (t , v ):
29+ return v
2430
2531
2632def _multicall (
@@ -57,7 +63,7 @@ def _multicall(
5763 # If this cast is not valid, a type error is raised below,
5864 # which is the desired response.
5965 res = hook_impl .function (* args )
60- wrapper_gen = cast (Generator [None , Result [object ], None ], res )
66+ wrapper_gen = cast (" Generator[None, Result[object], None]" , res )
6167 next (wrapper_gen ) # first yield
6268 teardowns .append ((wrapper_gen ,))
6369 except StopIteration :
@@ -67,7 +73,7 @@ def _multicall(
6773 # If this cast is not valid, a type error is raised below,
6874 # which is the desired response.
6975 res = hook_impl .function (* args )
70- function_gen = cast (Generator [None , object , object ], res )
76+ function_gen = cast (" Generator[None, object, object]" , res )
7177 next (function_gen ) # first yield
7278 teardowns .append (function_gen )
7379 except StopIteration :
0 commit comments