diff --git a/retryhttp/_retry.py b/retryhttp/_retry.py index 3c5d796..0f44ba0 100644 --- a/retryhttp/_retry.py +++ b/retryhttp/_retry.py @@ -1,4 +1,4 @@ -from typing import Any, Callable, Optional, Sequence, Tuple, Type, Union +from typing import Any, Optional, Sequence, Tuple, Type, Union from tenacity import ( RetryCallState, @@ -25,7 +25,7 @@ def retry( - func: Optional[Callable] = None, + func: Optional[F] = None, *, max_attempt_number: int = 3, retry_server_errors: bool = True, @@ -42,7 +42,7 @@ def retry( ] = None, timeouts: Union[Type[BaseException], Tuple[Type[BaseException], ...], None] = None, **kwargs: Any, -) -> Any: +) -> F: """Retry potentially transient HTTP errors with sensible default behavior. By default, retries the following errors, for a total of 3 attempts, with diff --git a/retryhttp/_utils.py b/retryhttp/_utils.py index 4643ee6..b33f11c 100644 --- a/retryhttp/_utils.py +++ b/retryhttp/_utils.py @@ -22,9 +22,9 @@ pass -def get_default_network_errors() -> ( - Tuple[Union[Type[httpx.NetworkError], Type[requests.ConnectionError]], ...] -): +def get_default_network_errors() -> Tuple[ + Union[Type[httpx.NetworkError], Type[requests.ConnectionError]], ... +]: """Get all network errors to use by default. Args: @@ -56,9 +56,9 @@ def get_default_network_errors() -> ( return tuple(exceptions) -def get_default_timeouts() -> ( - Tuple[Type[Union[httpx.TimeoutException, requests.Timeout]], ...] -): +def get_default_timeouts() -> Tuple[ + Type[Union[httpx.TimeoutException, requests.Timeout]], ... +]: """Get all timeout exceptions to use by default. Returns: @@ -73,9 +73,9 @@ def get_default_timeouts() -> ( return tuple(exceptions) -def get_default_http_status_exceptions() -> ( - Tuple[Union[Type[httpx.HTTPStatusError], Type[requests.HTTPError]], ...] -): +def get_default_http_status_exceptions() -> Tuple[ + Union[Type[httpx.HTTPStatusError], Type[requests.HTTPError]], ... +]: """Get default HTTP status 4xx or 5xx exceptions. Returns: