Skip to content

Commit d155540

Browse files
authored
httpx: update type hints to RequestInfo/ResponseInfo (#3105)
1 parent f8b0f72 commit d155540

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
1212
## Unreleased
1313

14+
### Fixed
15+
16+
- `opentelemetry-instrumentation-httpx` Fix `RequestInfo`/`ResponseInfo` type hints
17+
([#3105](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3105))
18+
1419
## Version 1.29.0/0.50b0 (2024-12-11)
1520

1621
### Added

docs/nitpick-exceptions.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ py-class=
2929
httpx.SyncByteStream
3030
httpx.AsyncByteStream
3131
httpx.Response
32+
httpx.URL
33+
httpx.Headers
3234
aiohttp.web_request.Request
3335
yarl.URL
3436
cimpl.Producer

instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ async def async_response_hook(span, request, response):
192192
---
193193
"""
194194

195+
from __future__ import annotations
196+
195197
import logging
196198
import typing
197199
from asyncio import iscoroutinefunction
@@ -249,8 +251,8 @@ async def async_response_hook(span, request, response):
249251

250252
class RequestInfo(typing.NamedTuple):
251253
method: bytes
252-
url: URL
253-
headers: typing.Optional[Headers]
254+
url: httpx.URL
255+
headers: httpx.Headers | None
254256
stream: typing.Optional[
255257
typing.Union[httpx.SyncByteStream, httpx.AsyncByteStream]
256258
]
@@ -259,7 +261,7 @@ class RequestInfo(typing.NamedTuple):
259261

260262
class ResponseInfo(typing.NamedTuple):
261263
status_code: int
262-
headers: typing.Optional[Headers]
264+
headers: httpx.Headers | None
263265
stream: typing.Iterable[bytes]
264266
extensions: typing.Optional[dict]
265267

0 commit comments

Comments
 (0)