Incorrect typing for Scope and Message in ASGIApp #2040
Replies: 3 comments 2 replies
-
Note that these broader types also generated issues with the latest version of opentelemetry-python-contrib. It would be great if the types could be fixed, or if the spec could be amended. Maybe @Kludex could have some insights as he has driven some typing efforts, or @tomchristie who added said types. |
Beta Was this translation helpful? Give feedback.
-
I don't think the issue is as simple as what you're proposing: I see that you're using a version of MyPy that is 3 years old. Maybe try updating mypy or using pyright? |
Beta Was this translation helpful? Give feedback.
-
What is the proposed solution here? |
Beta Was this translation helpful? Give feedback.
-
According to ASGI spec both scope and event message must be dictionaries, not an arbitrary mutable mapping:
and in other place:
But in starlette they are declared as
MutableMapping
:This actually breaks interoperability with other libraries that follows the spec. For example, the following code
gives the following error when type-checked with mypy:
The typing of ASGI app in httpx follows the spec:
Beta Was this translation helpful? Give feedback.
All reactions