]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Use typing `NoReturn` (#1412)
authorAmin Alaee <mohammadamin.alaee@gmail.com>
Fri, 14 Jan 2022 13:30:46 +0000 (14:30 +0100)
committerGitHub <noreply@github.com>
Fri, 14 Jan 2022 13:30:46 +0000 (14:30 +0100)
requirements.txt
starlette/datastructures.py
starlette/middleware/gzip.py
starlette/requests.py

index 48f3cfa3e7a8819498c48b656df0c718e375c10b..51389304e80950a024741d1b9a9fbf32dde82f2e 100644 (file)
@@ -8,7 +8,7 @@ coverage==6.2
 databases[sqlite]==0.5.3
 flake8==4.0.1
 isort==5.10.1
-mypy==0.930
+mypy==0.931
 types-requests==2.26.3
 types-contextvars==2.4.0
 types-PyYAML==6.0.1
index 52904d51e000af8f979521f9ab7989f70a518e8c..2c5c4b0165fb88d7a93c96d30e893263fb3fad94 100644 (file)
@@ -163,7 +163,7 @@ class URLPath(str):
 
     def __new__(cls, path: str, protocol: str = "", host: str = "") -> "URLPath":
         assert protocol in ("http", "websocket", "")
-        return str.__new__(cls, path)  # type: ignore
+        return str.__new__(cls, path)
 
     def __init__(self, path: str, protocol: str = "", host: str = "") -> None:
         self.protocol = protocol
@@ -441,7 +441,7 @@ class UploadFile:
 
     async def write(self, data: bytes) -> None:
         if self._in_memory:
-            self.file.write(data)  # type: ignore
+            self.file.write(data)
         else:
             await run_in_threadpool(self.file.write, data)
 
index 37c6936fad383dea7b922d90aafdf9b9bce65281..9d69ee7ca57535716c5698b5c07a8f1c4fdb2167 100644 (file)
@@ -1,5 +1,6 @@
 import gzip
 import io
+import typing
 
 from starlette.datastructures import Headers, MutableHeaders
 from starlette.types import ASGIApp, Message, Receive, Scope, Send
@@ -100,5 +101,5 @@ class GZipResponder:
             await self.send(message)
 
 
-async def unattached_send(message: Message) -> None:
+async def unattached_send(message: Message) -> typing.NoReturn:
     raise RuntimeError("send awaitable not set")  # pragma: no cover
index cf129702e06295c39add77db49a4ce6b9218b94b..a33367e1df9afb17277042205f21a368634395ab 100644 (file)
@@ -51,7 +51,7 @@ def cookie_parser(cookie_string: str) -> typing.Dict[str, str]:
         key, val = key.strip(), val.strip()
         if key or val:
             # unquote using Python's algorithm.
-            cookie_dict[key] = http_cookies._unquote(val)  # type: ignore
+            cookie_dict[key] = http_cookies._unquote(val)
     return cookie_dict
 
 
@@ -175,11 +175,11 @@ class HTTPConnection(Mapping):
         return url_path.make_absolute_url(base_url=self.base_url)
 
 
-async def empty_receive() -> Message:
+async def empty_receive() -> typing.NoReturn:
     raise RuntimeError("Receive channel has not been made available")
 
 
-async def empty_send(message: Message) -> None:
+async def empty_send(message: Message) -> typing.NoReturn:
     raise RuntimeError("Send channel has not been made available")