refactor: declare BaseAction's REPR_FIELDS and NAME as ClassVar - #680
Merged
mergify[bot] merged 2 commits intoAug 5, 2026
Conversation
This was referenced Aug 5, 2026
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:34
jd
force-pushed
the
devs/jd/chore/mypy-strictness/drop-always-true-truthiness-checks-enable-truthy--cb9981f6
branch
from
August 5, 2026 15:39
05deb5e to
7229e61
Compare
jd
force-pushed
the
devs/jd/chore/mypy-strictness/declare-baseaction-s-repr-fields-name-classvar--012caeaa
branch
from
August 5, 2026 15:39
83a4c19 to
227f834
Compare
Owner
Author
Revision history
|
Contributor
Merge Queue Status
This pull request spent 1 minute 56 seconds in the queue, including 10 seconds running CI. Waiting for
All conditions
ReasonPull request #680 has been dequeued Queue conditions are not satisfied:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Requeued — the merge queue status continues in this comment ↓. |
`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
jd
force-pushed
the
devs/jd/chore/mypy-strictness/drop-always-true-truthiness-checks-enable-truthy--cb9981f6
branch
from
August 5, 2026 15:47
7229e61 to
220001e
Compare
jd
force-pushed
the
devs/jd/chore/mypy-strictness/declare-baseaction-s-repr-fields-name-classvar--012caeaa
branch
from
August 5, 2026 15:47
227f834 to
4fc0664
Compare
Base automatically changed from
devs/jd/chore/mypy-strictness/drop-always-true-truthiness-checks-enable-truthy--cb9981f6
to
main
August 5, 2026 15:48
Contributor
Merge Queue Status
This pull request spent 1 minute in the queue, including 24 seconds running CI. Required conditions to merge
|
This was referenced Aug 5, 2026
mergify
Bot
deleted the
devs/jd/chore/mypy-strictness/declare-baseaction-s-repr-fields-name-classvar--012caeaa
branch
August 5, 2026 15:49
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.
mutable-overriderejects narrowing a mutable attribute in a subclass:RetryAction.REPR_FIELDS = ("sleep",)inferredtuple[str]against thebase's
Sequence[str], andNAME = "retry"inferredstragainststr | None. Both are unsound in general -- code holding aBaseActioncould assign a longer sequence or
Nonethrough the base type.BaseAction's docstring already calls these class variables, so mark themClassVarand repeat the base annotation on the override. This documentsthe extension point for subclasses outside tenacity too, which hit the
same error when they type check strictly.
Depends-On: #679