Skip to content

Commit 82b405b

Browse files
committed
Mark new exception blocks nocover (they weren't really covered before either)
1 parent 5c8b43b commit 82b405b

3 files changed

Lines changed: 22 additions & 22 deletions

File tree

httpcore/_backends/anyio.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ async def read(self, max_bytes: int, timeout: float | None = None) -> bytes:
2828
return await self._stream.receive(max_bytes=max_bytes)
2929
except anyio.EndOfStream: # pragma: nocover
3030
return b""
31-
except TimeoutError as exc:
31+
except TimeoutError as exc: # pragma: nocover
3232
raise ReadTimeout(exc) from exc
3333
except (
3434
anyio.BrokenResourceError,
3535
anyio.ClosedResourceError,
3636
anyio.EndOfStream,
37-
) as exc:
37+
) as exc: # pragma: nocover
3838
raise ReadError(exc) from exc
3939

4040
async def write(self, buffer: bytes, timeout: float | None = None) -> None:
@@ -44,9 +44,9 @@ async def write(self, buffer: bytes, timeout: float | None = None) -> None:
4444
try:
4545
with anyio.fail_after(timeout):
4646
await self._stream.send(item=buffer)
47-
except TimeoutError as exc:
47+
except TimeoutError as exc: # pragma: nocover
4848
raise WriteTimeout(exc) from exc
49-
except (anyio.BrokenResourceError, anyio.ClosedResourceError) as exc:
49+
except (anyio.BrokenResourceError, anyio.ClosedResourceError) as exc: # pragma: nocover
5050
raise WriteError(exc) from exc
5151

5252
async def aclose(self) -> None:
@@ -71,9 +71,9 @@ async def start_tls(
7171
except Exception as exc: # pragma: nocover
7272
await self.aclose()
7373
raise exc
74-
except TimeoutError as exc:
74+
except TimeoutError as exc: # pragma: nocover
7575
raise ConnectTimeout(exc) from exc
76-
except (anyio.BrokenResourceError, anyio.EndOfStream, ssl.SSLError) as exc:
76+
except (anyio.BrokenResourceError, anyio.EndOfStream, ssl.SSLError) as exc: # pragma: nocover
7777
raise ConnectError(exc) from exc
7878
return AnyIOStream(ssl_stream)
7979

httpcore/_backends/sync.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def read(self, max_bytes: int, timeout: float | None = None) -> bytes:
129129
try:
130130
self._sock.settimeout(timeout)
131131
return self._sock.recv(max_bytes)
132-
except socket.timeout as exc:
132+
except socket.timeout as exc: # pragma: nocover
133133
raise ReadTimeout(exc) from exc
134-
except OSError as exc:
134+
except OSError as exc: # pragma: nocover
135135
raise ReadError(exc) from exc
136136

137137
def write(self, buffer: bytes, timeout: float | None = None) -> None:
@@ -143,9 +143,9 @@ def write(self, buffer: bytes, timeout: float | None = None) -> None:
143143
self._sock.settimeout(timeout)
144144
n = self._sock.send(buffer)
145145
buffer = buffer[n:]
146-
except socket.timeout as exc:
146+
except socket.timeout as exc: # pragma: nocover
147147
raise WriteTimeout(exc) from exc
148-
except OSError as exc:
148+
except OSError as exc: # pragma: nocover
149149
raise WriteError(exc) from exc
150150

151151
def close(self) -> None:
@@ -174,9 +174,9 @@ def start_tls(
174174
except Exception as exc: # pragma: nocover
175175
self.close()
176176
raise exc
177-
except socket.timeout as exc:
177+
except socket.timeout as exc: # pragma: nocover
178178
raise ConnectTimeout(exc) from exc
179-
except OSError as exc:
179+
except OSError as exc: # pragma: nocover
180180
raise ConnectError(exc) from exc
181181
return SyncStream(sock)
182182

@@ -219,9 +219,9 @@ def connect_tcp(
219219
for option in socket_options:
220220
sock.setsockopt(*option) # pragma: no cover
221221
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
222-
except socket.timeout as exc:
222+
except socket.timeout as exc: # pragma: nocover
223223
raise ConnectTimeout(exc) from exc
224-
except OSError as exc:
224+
except OSError as exc: # pragma: nocover
225225
raise ConnectError(exc) from exc
226226
return SyncStream(sock)
227227

httpcore/_backends/trio.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ async def read(self, max_bytes: int, timeout: float | None = None) -> bytes:
2626
with trio.fail_after(timeout_or_inf):
2727
data: bytes = await self._stream.receive_some(max_bytes=max_bytes)
2828
return data
29-
except trio.TooSlowError as exc:
29+
except trio.TooSlowError as exc: # pragma: nocover
3030
raise ReadTimeout(exc) from exc
31-
except (trio.BrokenResourceError, trio.ClosedResourceError) as exc:
31+
except (trio.BrokenResourceError, trio.ClosedResourceError) as exc: # pragma: nocover
3232
raise ReadError(exc) from exc
3333

3434
async def write(self, buffer: bytes, timeout: float | None = None) -> None:
@@ -39,9 +39,9 @@ async def write(self, buffer: bytes, timeout: float | None = None) -> None:
3939
try:
4040
with trio.fail_after(timeout_or_inf):
4141
await self._stream.send_all(data=buffer)
42-
except trio.TooSlowError as exc:
42+
except trio.TooSlowError as exc: # pragma: nocover
4343
raise WriteTimeout(exc) from exc
44-
except (trio.BrokenResourceError, trio.ClosedResourceError) as exc:
44+
except (trio.BrokenResourceError, trio.ClosedResourceError) as exc: # pragma: nocover
4545
raise WriteError(exc) from exc
4646

4747
async def aclose(self) -> None:
@@ -68,9 +68,9 @@ async def start_tls(
6868
except Exception as exc: # pragma: nocover
6969
await self.aclose()
7070
raise exc
71-
except trio.TooSlowError as exc:
71+
except trio.TooSlowError as exc: # pragma: nocover
7272
raise ConnectTimeout(exc) from exc
73-
except trio.BrokenResourceError as exc:
73+
except trio.BrokenResourceError as exc: # pragma: nocover
7474
raise ConnectError(exc) from exc
7575
return TrioStream(ssl_stream)
7676

@@ -123,9 +123,9 @@ async def connect_tcp(
123123
)
124124
for option in socket_options:
125125
stream.setsockopt(*option) # type: ignore[attr-defined] # pragma: no cover
126-
except trio.TooSlowError as exc:
126+
except trio.TooSlowError as exc: # pragma: nocover
127127
raise ConnectTimeout(exc) from exc
128-
except (trio.BrokenResourceError, OSError) as exc:
128+
except (trio.BrokenResourceError, OSError) as exc: # pragma: nocover
129129
raise ConnectError(exc) from exc
130130
return TrioStream(stream)
131131

0 commit comments

Comments
 (0)