Skip to content

Commit 0461f64

Browse files
Tidy up
1 parent 590b568 commit 0461f64

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

src/ahttpx/_network.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import types
44
import typing
55

6+
import certifi
7+
68
from ._streams import Stream
79

8-
import certifi
910

1011
__all__ = ["NetworkBackend", "NetworkStream", "timeout"]
1112

src/ahttpx/_parsers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def __repr__(self) -> str:
350350
return f'<HTTPParser [{detail}]>'
351351

352352

353-
class ReadAheadParser(Stream):
353+
class ReadAheadParser:
354354
"""
355355
A buffered I/O stream, with methods for read-ahead parsing.
356356
"""
@@ -369,7 +369,7 @@ def _push_back(self, buffer):
369369
assert self._buffer == b''
370370
self._buffer = buffer
371371

372-
async def read(self, size: int=-1) -> bytes:
372+
async def read(self, size: int) -> bytes:
373373
"""
374374
Read and return up to 'size' bytes from the stream, with I/O buffering provided.
375375

src/httpx/_network.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
import types
1010
import typing
1111

12-
from ._streams import Stream
13-
1412
import certifi
1513

14+
from ._streams import Stream
1615

17-
_timeout_stack: contextvars.ContextVar[list[float]] = contextvars.ContextVar("timeout_context", default=[])
1816

1917
__all__ = ["NetworkBackend", "NetworkStream", "timeout"]
2018

19+
_timeout_stack: contextvars.ContextVar[list[float]] = contextvars.ContextVar("timeout_context", default=[])
20+
2121

2222
@contextlib.contextmanager
2323
def timeout(duration: float) -> typing.Iterator[None]:
@@ -82,10 +82,8 @@ def write(self, buffer: bytes) -> None:
8282

8383
def close(self) -> None:
8484
if not self._is_closed:
85-
timeout = get_current_timeout()
86-
self._socket.settimeout(timeout)
87-
self._socket.close()
8885
self._is_closed = True
86+
self._socket.close()
8987

9088
def __repr__(self):
9189
description = ""
@@ -96,7 +94,7 @@ def __repr__(self):
9694
def __del__(self):
9795
if not self._is_closed:
9896
import warnings
99-
warnings.warn("NetworkStream was garbage collected without being closed.")
97+
warnings.warn(f"NetworkStream was garbage collected without being closed.")
10098

10199
def __enter__(self) -> "NetworkStream":
102100
return self

src/httpx/_parsers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def __repr__(self) -> str:
350350
return f'<HTTPParser [{detail}]>'
351351

352352

353-
class ReadAheadParser(Stream):
353+
class ReadAheadParser:
354354
"""
355355
A buffered I/O stream, with methods for read-ahead parsing.
356356
"""
@@ -369,7 +369,7 @@ def _push_back(self, buffer):
369369
assert self._buffer == b''
370370
self._buffer = buffer
371371

372-
def read(self, size: int=-1) -> bytes:
372+
def read(self, size: int) -> bytes:
373373
"""
374374
Read and return up to 'size' bytes from the stream, with I/O buffering provided.
375375

0 commit comments

Comments
 (0)