Skip to content

Commit 1dd760e

Browse files
committed
chore: give every coverage pragma a reason (TS6, TS5)
1 parent e01f738 commit 1dd760e

19 files changed

Lines changed: 100 additions & 84 deletions

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,5 @@ markers = [
124124
[tool.coverage]
125125
run.concurrency = ["thread"]
126126
run.omit = ["benchmarks/*"]
127-
report.exclude_also = ["if typing.TYPE_CHECKING:", 'pytest\.fail\(']
127+
report.exclude_also = ["if typing.TYPE_CHECKING:"]
128128
report.fail_under = 100

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,5 @@ def check_event_loop(
3030
cached = get_loop()
3131
if cached is None:
3232
set_loop(current)
33-
# pragma below: inner double-check-with-lock race arm. Reachable only when two
34-
# threads pass the outer check and race for loop_lock — free-threaded CPython can
35-
# reach it, but only nondeterministically, so it stays excluded from coverage.
36-
elif cached is not current: # pragma: no cover
33+
elif cached is not current:
3734
raise RuntimeError(message_template.format(first=cached, current=current))

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ async def __call__(self, request: httpx2.Request, next: AsyncNext) -> httpx2.Res
250250
delay = self._policy.decide(attempt=attempt, request=request, exc=exc)
251251
await self._sleep(delay)
252252

253-
msg = "unreachable" # pragma: no cover
254-
raise AssertionError(msg) # pragma: no cover
253+
msg = "unreachable" # pragma: no cover — decide() raises on the final attempt
254+
raise AssertionError(msg) # pragma: no cover — decide() raises on the final attempt
255255

256256

257257
class Retry:
@@ -291,5 +291,5 @@ def __call__(self, request: httpx2.Request, next: Next) -> httpx2.Response: # n
291291
delay = self._policy.decide(attempt=attempt, request=request, exc=exc)
292292
self._sleep(delay)
293293

294-
msg = "unreachable" # pragma: no cover
295-
raise AssertionError(msg) # pragma: no cover
294+
msg = "unreachable" # pragma: no cover — decide() raises on the final attempt
295+
raise AssertionError(msg) # pragma: no cover — decide() raises on the final attempt

‎tests/test_circuit_breaker_props.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def test_open_circuit_never_forwards_before_reset_timeout(
4747
async def _ok(request: httpx2.Request) -> httpx2.Response:
4848
nonlocal forwarded
4949
forwarded += 1 # pragma: no cover — invariant: OPEN never forwards, so this never runs
50-
return httpx2.Response(200, request=request) # pragma: no cover
50+
return httpx2.Response(200, request=request) # pragma: no cover — invariant: OPEN never forwards
5151

5252
async def _five_hundred(request: httpx2.Request) -> httpx2.Response:
5353
raise InternalServerError(httpx2.Response(500, request=request))

‎tests/test_client_construction.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def test_default_decoders_includes_pydantic_when_installed() -> None:
5959

6060
def test_explicit_decoders_is_honored() -> None:
6161
class _Stub:
62-
def can_decode(self, model: type) -> bool: # noqa: ARG002 # pragma: no cover
62+
def can_decode(self, model: type) -> bool: # noqa: ARG002 # pragma: no cover — never invoked; the test only checks the stored decoders tuple
6363
return True
6464

65-
def decode(self, content: bytes, model: type) -> object: # noqa: ARG002 # pragma: no cover
65+
def decode(self, content: bytes, model: type) -> object: # noqa: ARG002 # pragma: no cover — never invoked; the test only checks the stored decoders tuple
6666
return None
6767

6868
stub = _Stub()
@@ -78,7 +78,7 @@ def test_empty_decoders_is_honored() -> None:
7878
async def test_missing_decoder_raised_before_http_call() -> None:
7979
"""response_model with no claiming decoder raises before the transport is invoked."""
8080

81-
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
81+
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover — never invoked; decoder check fails first
8282
pytest.fail("transport should not be invoked when MissingDecoderError fires")
8383

8484
transport = httpx2.MockTransport(handler)
@@ -114,7 +114,7 @@ def test_explicit_middleware_is_honored() -> None:
114114
captured: list[str] = []
115115

116116
class _Tag:
117-
async def __call__(self, request, next) -> httpx2.Response: # noqa: A002, ANN001 # pragma: no cover
117+
async def __call__(self, request, next) -> httpx2.Response: # noqa: A002, ANN001 # pragma: no cover — never invoked; the test only checks the stored middleware tuple
118118
captured.append("tag")
119119
return await next(request)
120120

‎tests/test_client_decoders_default.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ def test_async_empty_explicit_decoders() -> None:
4747

4848
def test_async_explicit_decoders_skip_default_probe() -> None:
4949
class _Custom:
50-
def can_decode(self, model: type) -> bool: # noqa: ARG002 # pragma: no cover
50+
def can_decode(self, model: type) -> bool: # noqa: ARG002 # pragma: no cover — never invoked; the test only checks the stored decoders tuple
5151
return True
5252

53-
def decode(self, content: bytes, model: type) -> object: # noqa: ARG002 # pragma: no cover
53+
def decode(self, content: bytes, model: type) -> object: # noqa: ARG002 # pragma: no cover — never invoked; the test only checks the stored decoders tuple
5454
return None
5555

5656
custom = _Custom()

‎tests/test_client_dispatch.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async def test_async_list_of_basemodel_routes_to_pydantic() -> None:
138138
async def test_async_missing_decoder_with_empty_list() -> None:
139139
"""Empty decoder list and response_model= raises before HTTP call."""
140140

141-
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
141+
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover — never invoked; decoder check fails first
142142
pytest.fail("transport should not be invoked")
143143

144144
transport = httpx2.MockTransport(handler)
@@ -158,10 +158,10 @@ class _Stub:
158158
def can_decode(self, model: type) -> bool: # noqa: ARG002
159159
return False
160160

161-
def decode(self, content: bytes, model: type) -> object: # noqa: ARG002 # pragma: no cover
161+
def decode(self, content: bytes, model: type) -> object: # noqa: ARG002 # pragma: no cover — never invoked; can_decode() rejects every model
162162
return None
163163

164-
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
164+
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover — never invoked; decoder check fails first
165165
pytest.fail("transport should not be invoked")
166166

167167
transport = httpx2.MockTransport(handler)
@@ -244,7 +244,7 @@ def test_sync_list_of_basemodel_routes_to_pydantic() -> None:
244244

245245

246246
def test_sync_missing_decoder_with_empty_list() -> None:
247-
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
247+
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover — never invoked; decoder check fails first
248248
pytest.fail("transport should not be invoked")
249249

250250
transport = httpx2.MockTransport(handler)
@@ -260,7 +260,7 @@ def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
260260
async def test_async_msgspec_only_list_of_basemodel_preflight_raises() -> None:
261261
"""MsgspecDecoder-only client raises MissingDecoderError for list[BaseModel] without sending a request."""
262262

263-
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
263+
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover — never invoked; decoder check fails first
264264
pytest.fail("transport should not be invoked: pre-flight must reject first")
265265

266266
transport = httpx2.MockTransport(handler)
@@ -276,7 +276,7 @@ def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
276276
def test_sync_msgspec_only_list_of_basemodel_preflight_raises() -> None:
277277
"""Sync MsgspecDecoder-only client raises MissingDecoderError for list[BaseModel] without sending a request."""
278278

279-
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
279+
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover — never invoked; decoder check fails first
280280
pytest.fail("transport should not be invoked: pre-flight must reject first")
281281

282282
transport = httpx2.MockTransport(handler)

‎tests/test_client_per_verb_with_response.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def test_with_response_decode_failure_raises_decode_error() -> None:
7373

7474

7575
async def test_with_response_missing_decoder_before_http_call() -> None:
76-
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
76+
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover — never invoked; decoder check fails first
7777
pytest.fail("transport should not be invoked when MissingDecoderError fires")
7878

7979
client = AsyncClient(httpx2_client=httpx2.AsyncClient(transport=httpx2.MockTransport(handler)), decoders=[])

‎tests/test_client_per_verb_with_response_sync.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_with_response_decode_failure_raises_decode_error() -> None:
7373

7474

7575
def test_with_response_missing_decoder_before_http_call() -> None:
76-
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
76+
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover — never invoked; decoder check fails first
7777
pytest.fail("transport should not be invoked when MissingDecoderError fires")
7878

7979
client = Client(httpx2_client=httpx2.Client(transport=httpx2.MockTransport(handler)), decoders=[])

‎tests/test_client_send_with_response.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def handler(request: httpx2.Request) -> httpx2.Response:
131131

132132

133133
async def test_send_with_response_raises_missing_decoder_before_http_call() -> None:
134-
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover
134+
def handler(_: httpx2.Request) -> httpx2.Response: # pragma: no cover — never invoked; decoder check fails first
135135
pytest.fail("transport should not be invoked when MissingDecoderError fires")
136136

137137
transport = httpx2.MockTransport(handler)

0 commit comments

Comments
 (0)