From 38eca679054946e4d0823af7d8823102dfd7d944 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Sat, 6 Apr 2024 15:05:47 +0200 Subject: [PATCH] Fix bug in run_with_retries, better types --- tests/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 817bdb9..a565c96 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -3,7 +3,10 @@ Helpers for testing. """ import time -from typing import Any, Callable +from typing import Callable, TypeVar + + +T = TypeVar("T") class MockResponse: @@ -24,7 +27,7 @@ def retval(val): return lambda *args, **kwargs: val -def run_with_retries(fn: Callable[..., Any]): +def run_with_retries(fn: Callable[..., T]) -> T: """ Run the the given function repeatedly until it finishes without raising an AssertionError. Sleep a bit between attempts. If the function doesn't @@ -41,4 +44,4 @@ def run_with_retries(fn: Callable[..., Any]): except AssertionError: time.sleep(delay) - fn() + return fn()