]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Use type literal for WebSocketEndpoint encoding values (#3027)
authorGonzalo Murillas <gmos2104@tutanota.com>
Sat, 20 Sep 2025 10:30:01 +0000 (12:30 +0200)
committerGitHub <noreply@github.com>
Sat, 20 Sep 2025 10:30:01 +0000 (03:30 -0700)
starlette/endpoints.py

index 2cdbeb116e2d21cf84a7ba1d658f710e63a577b4..bcf018ee0df24acc0ab94f475cb0908ca87886dc 100644 (file)
@@ -2,7 +2,7 @@ from __future__ import annotations
 
 import json
 from collections.abc import Generator
-from typing import Any, Callable
+from typing import Any, Callable, Literal
 
 from starlette import status
 from starlette._utils import is_async_callable
@@ -52,7 +52,7 @@ class HTTPEndpoint:
 
 
 class WebSocketEndpoint:
-    encoding: str | None = None  # May be "text", "bytes", or "json".
+    encoding: Literal["text", "bytes", "json"] | None = None
 
     def __init__(self, scope: Scope, receive: Receive, send: Send) -> None:
         assert scope["type"] == "websocket"