Skip to content

Commit 2e91519

Browse files
committed
fix(types): use MutableMapping to type call arguments in asgi middleware
When we bumped `opentelemetry-instrumentation-asgi` to 0.45b0, we got type errors due to the changes introduced by PR open-telemetry#2026. ``` error: Argument 1 to "add_middleware" of "Starlette" has incompatible type "type[AsgiMiddleware]"; expected "type[_MiddlewareClass[[]]]" [arg-type] ``` The problem is that it is specifying the types as `dict`, whereas Starlette requires `MutableMapping`. See https://github.com/encode/starlette/blob/9f16bf5c25e126200701f6e04330864f4a91a898/starlette/types.py#L10-L14. I first tried to change the type to `MutableMapping`, but that produces lot of extra changes as the code is not fully typed and we seem to be using `dict`s everywhere.
1 parent bd9156f commit 2e91519

File tree

1 file changed

+1
-6
lines changed
  • instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi

1 file changed

+1
-6
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,7 @@ def __init__(
553553
or []
554554
)
555555

556-
async def __call__(
557-
self,
558-
scope: dict[str, Any],
559-
receive: Callable[[], Awaitable[dict[str, Any]]],
560-
send: Callable[[dict[str, Any]], Awaitable[None]],
561-
) -> None:
556+
async def __call__(self, scope, receive, send) -> None:
562557
"""The ASGI application
563558
564559
Args:

0 commit comments

Comments
 (0)