tenacity icon indicating copy to clipboard operation
tenacity copied to clipboard

wait_chain passes retry_state as keyword, breaking callable wait strategies

Open Omarinho12345 opened this issue 2 weeks ago • 0 comments

Describe the bug

wait_chain invokes the selected strategy with retry_state as a keyword argument, so any wait strategy that takes the state positionally under another parameter name raises TypeError. The same callable works with wait=, wait_fixed(0) + callable and wait_combine(wait_fixed(0), callable), which call it positionally.

To Reproduce

from tenacity import retry, stop_after_attempt
from tenacity.wait import wait_chain, wait_combine, wait_fixed

def my_wait(rs):
    return 0.0

@retry(stop=stop_after_attempt(2), wait=wait_chain(wait_fixed(0), my_wait),
       sleep=lambda s: None)
def f():
    raise ValueError

f()
TypeError: my_wait() got an unexpected keyword argument 'retry_state'
  tenacity/wait.py:135, in wait_chain.__call__

Replacing the wait with wait_combine(wait_fixed(0), my_wait) or wait_fixed(0) + my_wait retries normally.

Expected behavior

wait_chain should call strategies the way wait_combine does (positionally), so any WaitBaseT callable works regardless of its parameter name.

Environment

tenacity main at aac059c, Python 3.14.

Fix

Call the strategy positionally in wait_chain.__call__, widen its signature to WaitBaseT like wait_combine, and add a regression test.

Omarinho12345 avatar Nov 19 '26 10:11 Omarinho12345