From f92996362b0401adb7156e2b84b11a8008521ac6 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Tue, 21 Jun 2022 20:33:29 +0200 Subject: [PATCH] Add missing string annotations --- uvicorn/middleware/proxy_headers.py | 2 +- uvicorn/middleware/wsgi.py | 5 ++++- uvicorn/protocols/http/h11_impl.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/uvicorn/middleware/proxy_headers.py b/uvicorn/middleware/proxy_headers.py index ff090cf2ff..4b62cf209e 100644 --- a/uvicorn/middleware/proxy_headers.py +++ b/uvicorn/middleware/proxy_headers.py @@ -50,7 +50,7 @@ async def __call__( self, scope: "Scope", receive: "ASGIReceiveCallable", send: "ASGISendCallable" ) -> None: if scope["type"] in ("http", "websocket"): - scope = cast(Union[HTTPScope, WebSocketScope], scope) + scope = cast(Union["HTTPScope", "WebSocketScope"], scope) client_addr: Optional[Tuple[str, int]] = scope.get("client") client_host = client_addr[0] if client_addr else None diff --git a/uvicorn/middleware/wsgi.py b/uvicorn/middleware/wsgi.py index e9f7fa1884..9a79a3baf6 100644 --- a/uvicorn/middleware/wsgi.py +++ b/uvicorn/middleware/wsgi.py @@ -79,7 +79,10 @@ def __init__(self, app: WSGIApp, workers: int = 10): self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=workers) async def __call__( - self, scope: HTTPScope, receive: ASGIReceiveCallable, send: ASGISendCallable + self, + scope: "HTTPScope", + receive: "ASGIReceiveCallable", + send: "ASGISendCallable", ) -> None: assert scope["type"] == "http" instance = WSGIResponder(self.app, self.executor, scope) diff --git a/uvicorn/protocols/http/h11_impl.py b/uvicorn/protocols/http/h11_impl.py index b7550dde82..a9632c6ea1 100644 --- a/uvicorn/protocols/http/h11_impl.py +++ b/uvicorn/protocols/http/h11_impl.py @@ -493,7 +493,7 @@ async def send(self, message: "ASGISendEvent") -> None: if message_type != "http.response.body": msg = "Expected ASGI message 'http.response.body', but got '%s'." raise RuntimeError(msg % message_type) - message = cast(HTTPResponseBodyEvent, message) + message = cast("HTTPResponseBodyEvent", message) body = message.get("body", b"") more_body = message.get("more_body", False)