Skip to content

feat: deprecate initial in favor of multiplier in wait_exponential_jitter#629

Merged
mergify[bot] merged 1 commit intomainfrom
devs/jd/feat/wait-exponential-jitter-multiplier/I63d23f41e58627085118b633a009c86ff2807f79
Mar 11, 2026
Merged

feat: deprecate initial in favor of multiplier in wait_exponential_jitter#629
mergify[bot] merged 1 commit intomainfrom
devs/jd/feat/wait-exponential-jitter-multiplier/I63d23f41e58627085118b633a009c86ff2807f79

Conversation

@jd
Copy link
Owner

@jd jd commented Mar 11, 2026

Every other exponential wait class uses multiplier. Having initial
only on wait_exponential_jitter is confusing. Add multiplier param
and deprecate initial as its alias.

  • Add multiplier parameter (default 1)
  • Emit DeprecationWarning when initial is used
  • Raise ValueError if both initial and multiplier are specified

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

@jd
Copy link
Owner Author

jd commented Mar 11, 2026

This pull request is part of a stack:

  1. feat: deprecate initial in favor of multiplier in wait_exponential_jitter (#629) 👈

Base automatically changed from devs/jd/feat/wait-exponential-jitter-multiplier/Ic02ae68b863cc0d1cd5a3b7874006c193c0c14a8 to main March 11, 2026 14:20
@jd jd force-pushed the devs/jd/feat/wait-exponential-jitter-multiplier/I63d23f41e58627085118b633a009c86ff2807f79 branch from a4d1d2e to 129d1a5 Compare March 11, 2026 14:24
…al_jitter`

Every other exponential wait class uses `multiplier`. Having `initial`
only on `wait_exponential_jitter` is confusing. Add `multiplier` param
and deprecate `initial` as its alias.

- Add `multiplier` parameter (default 1)
- Emit `DeprecationWarning` when `initial` is used
- Raise `ValueError` if both `initial` and `multiplier` are specified

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change-Id: I63d23f41e58627085118b633a009c86ff2807f79
@jd jd force-pushed the devs/jd/feat/wait-exponential-jitter-multiplier/I63d23f41e58627085118b633a009c86ff2807f79 branch from 129d1a5 to 333c1b5 Compare March 11, 2026 15:24
@jd jd marked this pull request as ready for review March 11, 2026 15:53
Copilot AI review requested due to automatic review settings March 11, 2026 15:53
@mergify mergify bot merged commit 1106b9a into main Mar 11, 2026
11 checks passed
@mergify mergify bot deleted the devs/jd/feat/wait-exponential-jitter-multiplier/I63d23f41e58627085118b633a009c86ff2807f79 branch March 11, 2026 15:54
@mergify
Copy link
Contributor

mergify bot commented Mar 11, 2026

Merge Queue Status

  • Entered queue2026-03-11 15:54 UTC · Rule: default
  • Checks passed · in-place
  • Merged2026-03-11 15:54 UTC · at 333c1b56370004d9fce4b634e9d2973b6920e6d7

This pull request spent 11 seconds in the queue, including 1 second running CI.

Required conditions to merge

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns wait_exponential_jitter with other exponential wait strategies by introducing a multiplier parameter and deprecating the older initial parameter (as an alias), including tests and a release note entry.

Changes:

  • Added multiplier parameter to wait_exponential_jitter and migrated internal computation to use it.
  • Added DeprecationWarning when initial is used, plus a ValueError for conflicting configuration.
  • Updated unit tests and added release notes covering the deprecation and new parameter.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tenacity/wait.py Adds multiplier, emits deprecation warning for initial, updates jitter backoff formula implementation.
tests/test_tenacity.py Updates existing test to assert deprecation warning and adds new tests for multiplier and conflict behavior.
releasenotes/notes/deprecate-initial-for-multiplier-c7b4e2d9f1a83065.yaml Documents the deprecation of initial and the new multiplier parameter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +267 to +272
if initial != 1:
warnings.warn(
"The 'initial' parameter is deprecated, use 'multiplier' instead",
DeprecationWarning,
stacklevel=2,
)
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecation warnings are currently only emitted when initial != 1. If a caller explicitly uses the deprecated parameter with the default value (e.g. initial=1), no DeprecationWarning is raised even though the deprecated API is being used. If the intent is to warn whenever initial is supplied, switch initial to a sentinel/None default and check initial is not None (then map it to multiplier).

Copilot uses AI. Check for mistakes.
Comment on lines +262 to +266
if initial != 1 and multiplier != 1:
raise ValueError(
"Cannot specify both 'initial' and 'multiplier' — use 'multiplier' only"
)

Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ValueError guard only triggers when both arguments are non-default (initial != 1 and multiplier != 1). This means callers can still pass both parameters without an error when initial is explicitly provided as the default (e.g. wait_exponential_jitter(initial=1, multiplier=10)), which contradicts the PR's stated behavior. Consider using a sentinel/None default for initial (or another way to detect whether it was provided) so you can reliably raise whenever initial is specified alongside multiplier.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants