Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Commit d9b9f01

Browse files
committed
Improve type hints for runtime, constant wait gens
This generators will work fine with floats for arguments. In the type hinting world, float can be used to mean int or float.
1 parent 52aef92 commit d9b9f01

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

backoff/_wait_gen.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def fibo(max_value: Optional[int] = None) -> Generator[int, None, None]:
5353

5454

5555
def constant(
56-
interval: Union[int, Iterable[int]] = 1
57-
) -> Generator[int, None, None]:
56+
interval: Union[int, Iterable[float]] = 1
57+
) -> Generator[Optional[float], None, None]:
5858
"""Generator for constant intervals.
5959
6060
Args:
@@ -72,7 +72,10 @@ def constant(
7272
yield val
7373

7474

75-
def runtime(*, value: Callable[[Any], int]) -> Generator[int, None, None]:
75+
def runtime(
76+
*,
77+
value: Callable[[Any], float]
78+
) -> Generator[Optional[float], None, None]:
7679
"""Generator that is based on parsing the return value or thrown
7780
exception of the decorated method
7881

0 commit comments

Comments
 (0)