Reformat code using black

Segments where readability was hampered were fixed by appropriate
format skipping directives. New code should hopefully be black
compatible. The moment they remove the -S option is probably the moment
I stop using black though.
This commit is contained in:
Rapptz
2022-02-20 06:29:41 -05:00
parent af8e74d327
commit 88b520b5ab
56 changed files with 738 additions and 289 deletions

View File

@ -31,9 +31,12 @@ from typing import Callable, Generic, Literal, TypeVar, overload, Union
T = TypeVar('T', bool, Literal[True], Literal[False])
# fmt: off
__all__ = (
'ExponentialBackoff',
)
# fmt: on
class ExponentialBackoff(Generic[T]):
"""An implementation of the exponential backoff algorithm
@ -62,14 +65,14 @@ class ExponentialBackoff(Generic[T]):
self._exp: int = 0
self._max: int = 10
self._reset_time: int = base * 2 ** 11
self._reset_time: int = base * 2**11
self._last_invocation: float = time.monotonic()
# Use our own random instance to avoid messing with global one
rand = random.Random()
rand.seed()
self._randfunc: Callable[..., Union[int, float]] = rand.randrange if integral else rand.uniform # type: ignore
self._randfunc: Callable[..., Union[int, float]] = rand.randrange if integral else rand.uniform # type: ignore
@overload
def delay(self: ExponentialBackoff[Literal[False]]) -> float:
@ -102,4 +105,4 @@ class ExponentialBackoff(Generic[T]):
self._exp = 0
self._exp = min(self._exp + 1, self._max)
return self._randfunc(0, self._base * 2 ** self._exp)
return self._randfunc(0, self._base * 2**self._exp)