Coverage for tubthumper/_types.py: 100%
18 statements
« prev ^ index » next coverage.py v7.4.0, created at 2024-01-09 04:23 +0000
« prev ^ index » next coverage.py v7.4.0, created at 2024-01-09 04:23 +0000
1"""Module of types used in tubthumper"""
3import sys
4from typing import Any, Iterable, Mapping, Optional, Tuple, Type, TypeVar, Union
6if sys.version_info < (3, 10):
7 from typing_extensions import ParamSpec, Protocol, TypeAlias
8else:
9 from typing import ParamSpec, Protocol, TypeAlias
12Exceptions: TypeAlias = Union[Type[Exception], Tuple[Type[Exception]]]
13Args: TypeAlias = Optional[Iterable[Any]]
14Kwargs: TypeAlias = Optional[Mapping[str, Any]]
15RetryLimit: TypeAlias = float
16Exponential: TypeAlias = float
17Jitter: TypeAlias = bool
18Reraise: TypeAlias = bool
19LogLevel: TypeAlias = int
20Duration: TypeAlias = float
22T = TypeVar("T")
23P = ParamSpec("P")
26class Logger(Protocol):
27 """
28 Generally a `logging.Logger`, but since we want to support
29 `duck-typing <https://docs.python.org/3/glossary.html#term-duck-typing>`_,
30 this is a `typing.Protocol` to enable
31 `structural subtyping <https://www.python.org/dev/peps/pep-0544/>`_.
32 """
34 def log(self, level: int, msg: str, *args: object, exc_info: bool) -> None:
35 r"""We call this method to log at the configured level with ``exc_info=True``
37 Args:
38 level:
39 the level of the message to be logged
40 msg:
41 the message to be logged
42 exc_info:
43 causes exception information to be added to the logging message
44 """