Skip to content

merge queue: checking main (7c3c45c), #678, #679, #680, #681 and #682 together - #689

Closed
mergify[bot] wants to merge 12 commits into
mainfrom
mergify/merge-queue/0e73288906
Closed

merge queue: checking main (7c3c45c), #678, #679, #680, #681 and #682 together#689
mergify[bot] wants to merge 12 commits into
mainfrom
mergify/merge-queue/0e73288906

Conversation

@mergify

@mergify mergify Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request has been checked successfully and will be merged soon. 🎉

Branch main (7c3c45c), #678, #679, #680, #681 and #682 are queued together for merge.

This pull request has been created by Mergify to speculatively check the mergeability of #682.
You don't need to do anything. Mergify will close this pull request automatically when it is complete.

Required conditions of queue rule default for merge:

Required conditions to stay in the queue:

---
checking_base_sha: bd886e51b38fb6ba149c00ee137d212b6979e4bd
previous_check_retries: []
previous_failed_batches: []
pull_requests:
  - number: 682
    scopes: []
scopes: []
...

jd and others added 12 commits August 5, 2026 17:38
`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
`strict = true` is a curated subset, not every check mypy has. These five
error codes and three flags are all off under `strict` and all report zero
errors on the current tree, so turning them on costs nothing today and
catches regressions from here on:

- `warn_unreachable` -- dead branches, which are usually a wrong annotation
  rather than dead code (see the `wait_base.__radd__` fix below this commit)
- `disallow_any_unimported` -- silent `Any` leaking in from untyped deps
- `extra_checks` -- unsafely overlapping operator signatures, among others
- `ignore-without-code` -- keeps `type: ignore` comments specific
- `redundant-expr`, `truthy-iterable`, `unused-awaitable`, `exhaustive-match`

Deliberately left off: `disallow_any_expr` (655 errors -- unusable for a
decorator library) and `disallow_any_decorated` (63 errors, all inherent to
`@retry` wrapping untyped test helpers).

Change-Id: I9eee43a749050d2bcf0aa0abbedf8725301eba18
`truthy-bool` reports objects tested for truthiness that implement neither
`__bool__` nor `__len__`, and so can only ever be true. Three sites:

`BaseRetrying._run_wait` and `AsyncRetrying._run_wait` both guarded the
wait call with `if self.wait:`. `wait` is typed `WaitBaseT` and defaults to
a `wait_none()` instance, so it is never falsy and the `sleep = 0.0` branch
has been dead since 17aefd9 -- a leftover from when the surrounding code
still used `if self.after is not None:` style guards. Call `self.wait`
unconditionally.

`if tornado:` guarded the optional import in two places. mypy only ever
sees the `try` branch, so it resolves the name to the module and reads the
test as always-true. Compute `_HAS_TORNADO` once and branch on that
instead; this also keeps `tornado.gen` fully typed, which annotating the
name as `ModuleType | None` would have thrown away.

Change-Id: Icb9981f6797707e070dc2423015f2fbf6c94e4c4
`mutable-override` rejects narrowing a mutable attribute in a subclass:
`RetryAction.REPR_FIELDS = ("sleep",)` inferred `tuple[str]` against the
base's `Sequence[str]`, and `NAME = "retry"` inferred `str` against
`str | None`. Both are unsound in general -- code holding a `BaseAction`
could assign a longer sequence or `None` through the base type.

`BaseAction`'s docstring already calls these class variables, so mark them
`ClassVar` and repeat the base annotation on the override. This documents
the extension point for subclasses outside tenacity too, which hit the
same error when they type check strictly.

Change-Id: I012caeaad2f93327c69467776a53e87c573b6403
Two more error codes mypy leaves off under `strict`, both with real hits
in the test suite.

`possibly-undefined`: `test_retry_state` bound `retry_state` only inside
an `except ExtractCallState` block, then used it unconditionally. Had the
retry stopped raising, the test would have failed with `NameError` instead
of a useful assertion. Use `assertRaises` as a context manager, which both
asserts the exception is raised and binds the state unconditionally.

`deprecated`: `asyncio.iscoroutinefunction` is deprecated since 3.14 and
removed in 3.16, and was emitting a `DeprecationWarning` on every test run.
The line right below it already asserts the same property via
`inspect.iscoroutinefunction`, which is the documented replacement, so drop
the deprecated call rather than pin the suite to an API that is going away.

Change-Id: I135cf5364f3e471d954c878f2599be7441104971
`explicit-override` is off under `strict`, and 63 methods across the
library and tests were overriding a base method without saying so. That
makes a whole class of change silently lossy: rename or drop a method on
`retry_base`/`wait_base`/`stop_base`/`BaseRetrying` and every subclass keeps
its now-orphaned implementation, still importable, never called again.

`typing.override` only exists from Python 3.12, and tenacity has no runtime
dependencies, so `_utils` imports it from `typing_extensions` under
TYPE_CHECKING (as the module already does for `Self`) and falls back to a
small PEP 698 shim at runtime on 3.10/3.11. Type checkers only ever see the
`typing_extensions` name, so the check works regardless of the interpreter
mypy runs under.

That last point exposed a second problem worth fixing here: mypy's
`python_version` defaults to whatever interpreter runs it, so CI on 3.14 was
never verifying that the code is valid on the 3.10 we claim to support. Pin
`python_version = "3.10"` to match `requires-python`. It caught one real
case immediately -- `RetryCallState.__getstate__` is only an override from
3.11 on, where `object.__getstate__` was introduced, so it must not carry
the decorator.

Verified `mypy` reports the same result under both a 3.10 and a 3.14
interpreter, and the runtime shim sets `__override__` correctly on 3.10.

Change-Id: Ide71dd204215e82012f6a9b1afc725dd7c5db8ee
@mergify mergify Bot closed this Aug 5, 2026
@mergify
mergify Bot deleted the mergify/merge-queue/0e73288906 branch August 5, 2026 15:43
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.

1 participant