fix: annotate wait_base.__radd__ as taking the int seed from sum() - #677
Merged
mergify[bot] merged 2 commits intoAug 5, 2026
Conversation
Owner
Author
|
This pull request is part of a Mergify stack:
|
This was referenced Aug 5, 2026
jd
marked this pull request as ready for review
August 5, 2026 15:24
Base automatically changed from
devs/jd/chore/mypy-strictness/drop-vestigial-tornado-ignore-missing-imports--1939167c
to
main
August 5, 2026 15:24
`on.pull_request.branches` filters on the *base* branch, not the head. With it pinned to `main`, only a pull request merging directly into `main` ran CI -- every stacked pull request, whose base is the branch below it in the stack, got no test, lint or mypy run at all and showed nothing but the Mergify checks. Drop the filter so CI runs for every pull request regardless of base. Change-Id: I1c211a106a57b9f4986bec4b76c0680c1a0f1b61
`__radd__` was annotated `other: wait_base`, which is the one type it can never receive: `wait_base.__add__` always succeeds, so Python never falls back to the reflected operator for two wait strategies. The only caller is `sum()`, which seeds its accumulator with the int 0 — hence the `type: ignore[comparison-overlap]` on `other == 0`, and the dead `return self` branch behind it that `--warn-unreachable` flags. Annotate the parameter as `int` and return `NotImplemented` for a non-zero left operand, so `5 + wait_fixed(1)` raises `TypeError` at the addition rather than building a `wait_combine` that explodes later when called. With the signature corrected, mypy infers `sum([...])` over wait strategies on its own, so four `type: ignore[list-item]` comments in `test_wait_arbitrary_sum` are no longer needed. Change-Id: Iad1bcef4412d6afc1a6f1335970cfbfcc4a34fcb
jd
force-pushed
the
devs/jd/chore/mypy-strictness/annotate-wait-base-radd-taking-int-seed-sum--ad1bcef4
branch
from
August 5, 2026 15:39
b02c344 to
ae08acf
Compare
jd
changed the base branch from
main
to
devs/jd/chore/mypy-strictness/run-pull-reqs-targeting-base-branch--1c211a10
August 5, 2026 15:39
Owner
Author
Revision history
|
Base automatically changed from
devs/jd/chore/mypy-strictness/run-pull-reqs-targeting-base-branch--1c211a10
to
main
August 5, 2026 15:41
Contributor
Merge Queue Status
This pull request spent 1 minute 2 seconds in the queue, including 25 seconds running CI. Required conditions to merge
|
This was referenced Aug 5, 2026
mergify
Bot
deleted the
devs/jd/chore/mypy-strictness/annotate-wait-base-radd-taking-int-seed-sum--ad1bcef4
branch
August 5, 2026 15:42
mergify Bot
pushed a commit
that referenced
this pull request
Aug 6, 2026
) Three runtime regressions from the mypy-strictness stack (#679, #677), all A/B verified against a2af454. None were caught by the test suite, and all three only fire once a retry actually happens, so happy-path callers see nothing until production. 1. `Retrying(wait=None)`, `wait=0` and `wait=sum([])` now raise `TypeError: 'NoneType' object is not callable` from inside `iter()`. #679 removed the `if self.wait:` guard on the grounds that `truthy-bool` proved it always true -- but that only holds for the *declared* type. Untyped callers pass `None`/`0` to mean "no wait", and `sum([])` over an empty strategy list returns the int 0. The `TypeError` is raised outside the attempt's try/except, so it escapes uncaught and destroys the caller's real exception. Restore the guard with a local `truthy-bool` suppression explaining why the "impossible" branch is reachable. `before`, `after`, `before_sleep` and `retry_error_callback` all kept their `is not None` guards; `wait` was the only one dropped. 2. `plain_callable + wait_strategy` now raises `TypeError`. `WaitBaseT` admits plain callables, and a function has no `__add__`, so this went through `wait_base.__radd__` -- which #677 narrowed to `int`. Widen it to `WaitBaseT | int` and build the `wait_combine` again. `5 + strategy` is still rejected, now via `NotImplemented` rather than a combination that fails later. The parameter stays `int` rather than `Literal[0]` because typeshed's `sum()` protocol requires `__radd__(x: int)`; narrowing it would make every `sum()` over strategies need a `type: ignore`. 3. `wait_combine.__call__` passed the state as `retry_state=`, which crashes on any `WaitBaseT` callable whose parameter has another name. Pass it positionally, as `BaseRetrying._run_wait` already does. Adds regression tests for all three plus the async path -- the original change shipped with no test covering any of them. Change-Id: Ia40c32a22cdac09cbfba4280fb0a7f0c2cb7b7e0
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.
__radd__was annotatedother: wait_base, which is the one type it cannever receive:
wait_base.__add__always succeeds, so Python never fallsback to the reflected operator for two wait strategies. The only caller is
sum(), which seeds its accumulator with the int 0 — hence thetype: ignore[comparison-overlap]onother == 0, and the deadreturn selfbranch behind it that--warn-unreachableflags.Annotate the parameter as
intand returnNotImplementedfor a non-zeroleft operand, so
5 + wait_fixed(1)raisesTypeErrorat the additionrather than building a
wait_combinethat explodes later when called.With the signature corrected, mypy infers
sum([...])over wait strategieson its own, so four
type: ignore[list-item]comments intest_wait_arbitrary_sumare no longer needed.Depends-On: #683