33import contextlib
44import ssl
55import typing
6- from collections .abc import AsyncIterator , Callable , Iterator , Mapping , Sequence
6+ from collections .abc import AsyncGenerator , Callable , Generator , Mapping , Sequence
77from http import HTTPStatus
88
99import httpx2
@@ -205,7 +205,7 @@ async def _send_capped_async(client: httpx2.AsyncClient, request: httpx2.Request
205205@contextlib .asynccontextmanager
206206async def _stream_async (
207207 client : httpx2 .AsyncClient , method : str , url : httpx2 .URL | str , kwargs : dict [str , typing .Any ]
208- ) -> AsyncIterator [httpx2 .Response ]:
208+ ) -> AsyncGenerator [httpx2 .Response ]:
209209 """Mirror of `httpx2.AsyncClient.stream` that builds via `_build_request`."""
210210 response = await client .send (_build_request (client , method , url , kwargs ), stream = True )
211211 try :
@@ -221,7 +221,7 @@ async def _stream_capped_async(
221221 url : httpx2 .URL | str ,
222222 kwargs : dict [str , typing .Any ],
223223 cap : int ,
224- ) -> AsyncIterator [httpx2 .Response ]:
224+ ) -> AsyncGenerator [httpx2 .Response ]:
225225 """Async mirror of `httpx2.AsyncClient.stream` that sends via `_send_capped_async`."""
226226 response = await _send_capped_async (client , _build_request (client , method , url , kwargs ), cap )
227227 try :
@@ -286,7 +286,7 @@ def _send_capped(client: httpx2.Client, request: httpx2.Request, cap: int) -> ht
286286@contextlib .contextmanager
287287def _stream (
288288 client : httpx2 .Client , method : str , url : httpx2 .URL | str , kwargs : dict [str , typing .Any ]
289- ) -> Iterator [httpx2 .Response ]:
289+ ) -> Generator [httpx2 .Response ]:
290290 """Sync mirror of `_stream_async`."""
291291 response = client .send (_build_request (client , method , url , kwargs ), stream = True )
292292 try :
@@ -302,7 +302,7 @@ def _stream_capped(
302302 url : httpx2 .URL | str ,
303303 kwargs : dict [str , typing .Any ],
304304 cap : int ,
305- ) -> Iterator [httpx2 .Response ]:
305+ ) -> Generator [httpx2 .Response ]:
306306 """Sync mirror of `_stream_capped_async`."""
307307 response = _send_capped (client , _build_request (client , method , url , kwargs ), cap )
308308 try :
@@ -1221,7 +1221,7 @@ async def stream( # noqa: PLR0913 — mirrors httpx2 per-method signatures; kwa
12211221 content : typing .Any | None = None ,
12221222 data : typing .Any | None = None ,
12231223 files : typing .Any | None = None ,
1224- ) -> AsyncIterator [httpx2 .Response ]:
1224+ ) -> AsyncGenerator [httpx2 .Response ]:
12251225 """Stream an HTTP response. Bypasses the middleware chain.
12261226
12271227 Yields an httpx2.Response; consume the body via response.aiter_bytes(),
@@ -2180,7 +2180,7 @@ def stream( # noqa: PLR0913 — mirrors httpx2 per-method signatures; kwargs-fo
21802180 content : typing .Any | None = None ,
21812181 data : typing .Any | None = None ,
21822182 files : typing .Any | None = None ,
2183- ) -> Iterator [httpx2 .Response ]:
2183+ ) -> Generator [httpx2 .Response ]:
21842184 """Stream an HTTP response. Bypasses the middleware chain.
21852185
21862186 Yields an httpx2.Response; consume the body via response.iter_bytes(),
0 commit comments