Skip to content

Commit

Permalink
Improve type hints for runtime, constant wait gens
Browse files Browse the repository at this point in the history
This generators will work fine with floats for arguments. In the type
hinting world, float can be used to mean int or float.
  • Loading branch information
bgreen-litl committed Oct 5, 2022
1 parent 52aef92 commit d9b9f01
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions backoff/_wait_gen.py
Expand Up @@ -53,8 +53,8 @@ def fibo(max_value: Optional[int] = None) -> Generator[int, None, None]:


def constant(
interval: Union[int, Iterable[int]] = 1
) -> Generator[int, None, None]:
interval: Union[int, Iterable[float]] = 1
) -> Generator[Optional[float], None, None]:
"""Generator for constant intervals.
Args:
Expand All @@ -72,7 +72,10 @@ def constant(
yield val


def runtime(*, value: Callable[[Any], int]) -> Generator[int, None, None]:
def runtime(
*,
value: Callable[[Any], float]
) -> Generator[Optional[float], None, None]:
"""Generator that is based on parsing the return value or thrown
exception of the decorated method
Expand Down

0 comments on commit d9b9f01

Please sign in to comment.