fix: call wait_chain members positionally - #699
Open
codechrl wants to merge 1 commit into
Open
Conversation
wait_chain.__call__ calls each member strategy as wait_func(retry_state=retry_state). WaitBaseT admits plain callables, which accept the state positionally without naming the parameter retry_state. Such a member raises TypeError on the first retry. The same callable works as wait=, because _run_wait calls it positionally. jd#694 fixed the same call convention in wait_combine and widened wait_combine.__init__ to WaitBaseT.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wait_chain.__call__calls each member strategy aswait_func(retry_state=retry_state).WaitBaseTisCallable[[RetryCallState], float | int], so a plain callable takes thestate positionally and need not name its parameter
retry_state. Such amember raises
TypeError: <lambda>() got an unexpected keyword argument 'retry_state'.The effect is that a plain callable cannot be used inside a
wait_chain,which is the combinator for phase-based backoff. The same callable works as
wait=, becauseBaseRetrying._run_waitcalls it positionally. The failureneeds both a
wait_chainand an attempt that retries, so it surfaces at thefirst retry rather than at construction.
The fix passes the state positionally and widens
wait_chain(*strategies)from
wait_basetoWaitBaseT. #694 made both changes forwait_combine.tenacity/asynciodoes not overridewait_chain.A/B verified against
26f719d:test_wait_chain_passes_state_positionallyfails with the
TypeErrorabove before the change and passes after.Reverting the
tenacity/wait.pyhunk alone puts it back to failing. Releasenote added under
releasenotes/notes/.