Installing asgi_app middleware as documented results in type errors
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Read the middleware guide and Quart.asgi_app reference linked in the issue, then reproduce the example with Python 3.12.8, Quart 0.20.0, OpenTelemetryMiddleware, and mypy 1.15.0. Trace the declared type of app.asgi_app and the middleware callable. Done means the documented installation path is accurate and the reported mypy errors are addressed or clearly documented.
Written by the indexing model from the issue text.
Description
The documentation in
https://quart.palletsprojects.com/en/latest/how_to_guides/middleware/
and
https://quart.palletsprojects.com/en/latest/reference/source/quart.app/#quart.app.Quart.asgi_app
says to install middleware using a pattern like:
app.asgi_app = middleware(app.asgi_app)
However, following that pattern in practice produces type errors with mypy 1.15.0.
After adding
from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware
and
app.asgi_app = OpenTelemetryMiddleware(app.asgi_app)
I see:
app.py:388: error: Cannot assign to a method [method-assign]
app.py:388: error: Incompatible types in assignment (expression has type "OpenTelemetryMiddleware", variable has type "Callable[[HTTPScope | WebsocketScope | LifespanScope, Callable[[], Awaitable[HTTPRequestEvent | HTTPDisconnectEvent | WebsocketConnectEvent | WebsocketReceiveEvent | WebsocketDisconnectEvent | LifespanStartupEvent | LifespanShutdownEvent]], Callable[[HTTPResponseStartEvent | HTTPResponseBodyEvent | HTTPResponseTrailersEvent | HTTPServerPushEvent | HTTPEarlyHintEvent | <10 more items>], Awaitable[None]]], Coroutine[Any, Any, None]]") [assignment]
app.py:388: note: "OpenTelemetryMiddleware.__call__" has type "Callable[[Arg(dict[str, Any], 'scope'), Arg(Callable[[], Awaitable[dict[str, Any]]], 'receive'), Arg(Callable[[dict[str, Any]], Awaitable[None]], 'send')], Coroutine[Any, Any, None]]"
Environment:
- Python version: 3.12.8
- Quart version: 0.20.0
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 206
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pallets/quart
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·