Skip to content

Commit c8bedef

Browse files
committed
ref(types): make ASGI scope fields http_version and method optional to
support WebSocket
1 parent 5aec8b3 commit c8bedef

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sentry_sdk/_types.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,20 @@ class SDKInfo(TypedDict):
278278
# TODO: Make a proper type definition for this (PRs welcome!)
279279
BreadcrumbHint = Dict[str, Any]
280280

281-
_ASGIInfo = TypedDict("_ASGIInfo", {"version": str, "spec_version": str})
281+
_ASGIInfo = TypedDict(
282+
"_ASGIInfo", {"version": str, "spec_version": NotRequired[str]}
283+
)
282284
_ASGIScope = TypedDict(
283285
"_ASGIScope",
284286
{
285287
"type": str,
286288
"asgi": _ASGIInfo,
287-
"http_version": str,
288-
"method": str,
289289
"path": str,
290290
"query_string": bytes,
291291
"headers": list[tuple[bytes, bytes]],
292+
# Not mandatory in Websocket
293+
"http_version": NotRequired[str],
294+
"method": NotRequired[str],
292295
# Optional fields per ASGI spec
293296
"scheme": NotRequired[str],
294297
"raw_path": NotRequired[bytes],

0 commit comments

Comments
 (0)