diff --git a/requirements.txt b/requirements.txt index 48f3cfa3e..51389304e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/starlette/datastructures.py b/starlette/datastructures.py index 52904d51e..2c5c4b016 100644 --- a/starlette/datastructures.py +++ b/starlette/datastructures.py @@ -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 @@ def _in_memory(self) -> bool: 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) diff --git a/starlette/middleware/gzip.py b/starlette/middleware/gzip.py index 37c6936fa..9d69ee7ca 100644 --- a/starlette/middleware/gzip.py +++ b/starlette/middleware/gzip.py @@ -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 @@ async def send_with_gzip(self, message: Message) -> None: 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 diff --git a/starlette/requests.py b/starlette/requests.py index cf129702e..a33367e1d 100644 --- a/starlette/requests.py +++ b/starlette/requests.py @@ -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 @@ def url_for(self, name: str, **path_params: typing.Any) -> str: 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")