pre-commit linting (#259)

* pre-commit linting

* fix pydocs
This commit is contained in:
Henning Jacobs
2020-04-25 21:01:21 +02:00
committed by GitHub
parent b409e4f375
commit 76a498bacc
23 changed files with 567 additions and 335 deletions

View File

@@ -7,11 +7,14 @@ def expo(n: int, base=2, factor=1, max_value=None):
Adapted from https://github.com/litl/backoff/blob/master/backoff.py (MIT License)
Args:
----
n: The exponent.
base: The mathematical base of the exponentiation operation
factor: Factor to multiply the exponentation by.
max_value: The maximum value to yield. Once the value in the
true exponential sequence exceeds this, the value
of max_value will forever after be yielded.
"""
a = factor * base ** n
if max_value is None or a < max_value:
@@ -27,8 +30,12 @@ def random_jitter(value, jitter=1):
This adds up to 1 second of additional time to the original value.
Prior to backoff version 1.2 this was the default jitter behavior.
Args:
----
value: The unadulterated backoff value.
jitter: Jitter amount.
"""
return value + random.uniform(0, jitter)
@@ -43,6 +50,8 @@ def full_jitter(value):
(http://www.awsarchitectureblog.com/2015/03/backoff.html)
Args:
----
value: The unadulterated backoff value.
"""
return random.uniform(0, value)