Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/backoff/_typing.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:35 +0000

1# coding:utf-8 

2import logging 

3import sys 

4from typing import (Any, Callable, Coroutine, Dict, Generator, Sequence, Tuple, 

5 TypeVar, Union) 

6 

7if sys.version_info >= (3, 8): # pragma: no cover 

8 from typing import TypedDict 

9else: # pragma: no cover 

10 # use typing_extensions if installed but don't require it 

11 try: 

12 from typing_extensions import TypedDict 

13 except ImportError: 

14 class TypedDict(dict): 

15 def __init_subclass__(cls, **kwargs: Any) -> None: 

16 return super().__init_subclass__() 

17 

18 

19class _Details(TypedDict): 

20 target: Callable[..., Any] 

21 args: Tuple[Any, ...] 

22 kwargs: Dict[str, Any] 

23 tries: int 

24 elapsed: float 

25 

26 

27class Details(_Details, total=False): 

28 wait: float # present in the on_backoff handler case for either decorator 

29 value: Any # present in the on_predicate decorator case 

30 

31 

32T = TypeVar("T") 

33 

34_CallableT = TypeVar('_CallableT', bound=Callable[..., Any]) 

35_Handler = Union[ 

36 Callable[[Details], None], 

37 Callable[[Details], Coroutine[Any, Any, None]], 

38] 

39_Jitterer = Callable[[float], float] 

40_MaybeCallable = Union[T, Callable[[], T]] 

41_MaybeLogger = Union[str, logging.Logger, None] 

42_MaybeSequence = Union[T, Sequence[T]] 

43_Predicate = Callable[[T], bool] 

44_WaitGenerator = Callable[..., Generator[float, None, None]]