| |
| import logging |
| import sys |
| from typing import (Any, Callable, Coroutine, Dict, Generator, Sequence, Tuple, |
| TypeVar, Union) |
|
|
| if sys.version_info >= (3, 8): |
| from typing import TypedDict |
| else: |
| |
| try: |
| from typing_extensions import TypedDict |
| except ImportError: |
| class TypedDict(dict): |
| def __init_subclass__(cls, **kwargs: Any) -> None: |
| return super().__init_subclass__() |
|
|
|
|
| class _Details(TypedDict): |
| target: Callable[..., Any] |
| args: Tuple[Any, ...] |
| kwargs: Dict[str, Any] |
| tries: int |
| elapsed: float |
|
|
|
|
| class Details(_Details, total=False): |
| wait: float |
| value: Any |
|
|
|
|
| T = TypeVar("T") |
|
|
| _CallableT = TypeVar('_CallableT', bound=Callable[..., Any]) |
| _Handler = Union[ |
| Callable[[Details], None], |
| Callable[[Details], Coroutine[Any, Any, None]], |
| ] |
| _Jitterer = Callable[[float], float] |
| _MaybeCallable = Union[T, Callable[[], T]] |
| _MaybeLogger = Union[str, logging.Logger, None] |
| _MaybeSequence = Union[T, Sequence[T]] |
| _Predicate = Callable[[T], bool] |
| _WaitGenerator = Callable[..., Generator[float, None, None]] |
|
|