]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Fix Mypy errors in routing and testclient (#1372)
authorAmin Alaee <mohammadamin.alaee@gmail.com>
Thu, 16 Dec 2021 09:45:05 +0000 (10:45 +0100)
committerGitHub <noreply@github.com>
Thu, 16 Dec 2021 09:45:05 +0000 (10:45 +0100)
* Fix Mypy errors in routing and testclient

* Update starlette/testclient.py

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
starlette/routing.py
starlette/testclient.py

index 982980c3ce1969001944c11de8f4867bf7eeb69c..a7d72cb55ce326b19a8f729031efb83570b0e821 100644 (file)
@@ -349,7 +349,7 @@ class Mount(BaseRoute):
 
     @property
     def routes(self) -> typing.List[BaseRoute]:
-        return getattr(self.app, "routes", None)
+        return getattr(self.app, "routes", [])
 
     def matches(self, scope: Scope) -> typing.Tuple[Match, Scope]:
         if scope["type"] in ("http", "websocket"):
@@ -427,7 +427,7 @@ class Host(BaseRoute):
 
     @property
     def routes(self) -> typing.List[BaseRoute]:
-        return getattr(self.app, "routes", None)
+        return getattr(self.app, "routes", [])
 
     def matches(self, scope: Scope) -> typing.Tuple[Match, Scope]:
         if scope["type"] in ("http", "websocket"):
index 08d03fa5c4297fc1d5322c9a3ff951e9de747abd..40220fb4d8c93b8930d58523ff3c27c72000d15e 100644 (file)
@@ -151,6 +151,8 @@ class _ASGIAdapter(requests.adapters.HTTPAdapter):
             for key, value in request.headers.items()
         ]
 
+        scope: typing.Dict[str, typing.Any]
+
         if scheme in {"ws", "wss"}:
             subprotocol = request.headers.get("sec-websocket-protocol", None)
             if subprotocol is None: