self._is_stream_consumed = True
if hasattr(self._stream, "read"):
# File-like interfaces should use 'read' directly.
- chunk = self._stream.read(self.CHUNK_SIZE) # type: ignore
+ chunk = self._stream.read(self.CHUNK_SIZE)
while chunk:
yield chunk
- chunk = self._stream.read(self.CHUNK_SIZE) # type: ignore
+ chunk = self._stream.read(self.CHUNK_SIZE)
else:
# Otherwise iterate.
for part in self._stream:
self._is_stream_consumed = True
if hasattr(self._stream, "aread"):
# File-like interfaces should use 'aread' directly.
- chunk = await self._stream.aread(self.CHUNK_SIZE) # type: ignore
+ chunk = await self._stream.aread(self.CHUNK_SIZE)
while chunk:
yield chunk
- chunk = await self._stream.aread(self.CHUNK_SIZE) # type: ignore
+ chunk = await self._stream.aread(self.CHUNK_SIZE)
else:
# Otherwise iterate.
async for part in self._stream:
def encode_content(
content: Union[str, bytes, Iterable[bytes], AsyncIterable[bytes]]
) -> Tuple[Dict[str, str], Union[SyncByteStream, AsyncByteStream]]:
-
if isinstance(content, (bytes, str)):
body = content.encode("utf-8") if isinstance(content, str) else content
content_length = len(body)
def close(self) -> None:
if hasattr(self._httpcore_stream, "close"):
- self._httpcore_stream.close() # type: ignore
+ self._httpcore_stream.close()
class HTTPTransport(BaseTransport):
async def aclose(self) -> None:
if hasattr(self._httpcore_stream, "aclose"):
- await self._httpcore_stream.aclose() # type: ignore
+ await self._httpcore_stream.aclose()
class AsyncHTTPTransport(AsyncBaseTransport):