Skip to content

Commit 14a7d5e

Browse files
lesnik512claude
andcommitted
docs(resilience): clarify __cause__ assignment + pragma rationale
- retry.py: add inline comment to wrapped.__cause__ = exc explaining it is load-bearing on the retry path (last_exc = wrapped) where no `raise ... from ...` clause sets the cause. Prevents future "cleanup" that silently breaks exhaustion chain display. - test_retry.py: expand the pragma rationale to record how it was verified the assertions still execute (intentional break → test fails). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 365cd5a commit 14a7d5e

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/httpware/middleware/resilience/retry.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def __call__(self, request: httpx2.Request, next: Next) -> httpx2.Response
9898
last_response = None
9999
except builtins.TimeoutError as exc:
100100
wrapped = TimeoutError("attempt timed out")
101-
wrapped.__cause__ = exc
101+
wrapped.__cause__ = exc # set now; the retry path (last_exc = wrapped) has no `from` clause
102102
if not method_eligible:
103103
raise wrapped from exc
104104
last_exc = wrapped

‎tests/test_retry.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ async def handler_async(request: httpx2.Request) -> httpx2.Response:
255255
middleware=[Retry(_sleep=sleeper, attempt_timeout=0.05, base_delay=0.01, max_delay=0.02)],
256256
)
257257
response = await client.get("https://example.test/x")
258-
# coverage: asyncio.timeout fires a CancelledError that the retry loop catches; coverage's
259-
# thread tracer loses the coroutine frame at that point. These assertions DO execute
260-
# (the test passes), but need the pragma to satisfy the fail-under=100 gate.
258+
# coverage[thread] loses the coroutine frame after asyncio.timeout-induced cancellation.
259+
# The assertions DO execute — verified by intentionally breaking them (test fails as
260+
# expected). Pragmas mask a tooling limitation, not dead code.
261261
assert response.status_code == HTTPStatus.OK # pragma: no cover
262262
assert call_count["n"] == 2 # pragma: no cover # noqa: PLR2004 — "2" is intentional literal in test assertion
263263

0 commit comments

Comments
 (0)