From 2f46b2b6f62be436b56bb2ddbe5b751d7bf3ab18 Mon Sep 17 00:00:00 2001 From: Nikolay Bryskin Date: Sun, 13 Apr 2025 14:51:28 +0300 Subject: [PATCH] Refactor: Use kwargs.pop for decorator arguments - Changed `kwargs.get()` to `kwargs.pop()` for `retry`, `wait`, and `stop` in `retryhttp/_retry.py`. - Ensures these arguments are consumed by the decorator and not passed down to `tenacity.retry`, preventing potential conflicts. --- retryhttp/_retry.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retryhttp/_retry.py b/retryhttp/_retry.py index bfbc99c..421398f 100644 --- a/retryhttp/_retry.py +++ b/retryhttp/_retry.py @@ -145,18 +145,18 @@ def retry( if not retry_strategies: raise RuntimeError("No retry strategies enabled.") - retry = kwargs.get("retry") or retry_any(*retry_strategies) + retry = kwargs.pop("retry", None) or retry_any(*retry_strategies) # We don't need to conditionally build our wait strategy since each strategy # will only apply if the corresponding retry strategy is in use. - wait = kwargs.get("wait") or wait_context_aware( + wait = kwargs.pop("wait", None) or wait_context_aware( wait_server_errors=wait_server_errors, wait_network_errors=wait_network_errors, wait_timeouts=wait_timeouts, wait_rate_limited=wait_rate_limited, ) - stop = kwargs.get("stop") or stop_after_attempt(max_attempt_number) + stop = kwargs.pop("stop", None) or stop_after_attempt(max_attempt_number) def decorator(func: F) -> F: return tenacity_retry(retry=retry, wait=wait, stop=stop, **kwargs)(func)