merge queue: checking main (e6ef84a), #680 and #681 together - #691
Closed
mergify[bot] wants to merge 5 commits into
Closed
merge queue: checking main (e6ef84a), #680 and #681 together#691mergify[bot] wants to merge 5 commits into
mergify[bot] wants to merge 5 commits into
Conversation
`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
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.
🎉 This pull request has been checked successfully and will be merged soon. 🎉
Branch main (e6ef84a), #680 and #681 are queued together for merge.
This pull request has been created by Mergify to speculatively check the mergeability of #681.
You don't need to do anything. Mergify will close this pull request automatically when it is complete.
Required conditions of queue rule
defaultfor merge:depends-on = jd/tenacity#680[⛓️ refactor: declare BaseAction's REPR_FIELDS and NAME as ClassVar #680]github-review-approved[🛡 GitHub branch protection]Required conditions to stay in the queue:
check-success=test (3.10, check)check-success=test (3.11, check)check-success=test (3.12, check)check-success=test (3.13, check)check-success=test (3.14, check)check-success=test (3.14, lint)check-success=test (3.14, mypy)depends-on = jd/tenacity#680[⛓️ refactor: declare BaseAction's REPR_FIELDS and NAME as ClassVar #680]github-review-approved[🛡 GitHub branch protection]author = jd#approved-reviews-by >= 1author = dependabot[bot]