Skip to content

Commit

Permalink
Use typing NoReturn (#1412)
Browse files Browse the repository at this point in the history
  • Loading branch information
aminalaee committed Jan 14, 2022
1 parent 7d79ad9 commit fcc4c70
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions starlette/datastructures.py
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion 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
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions starlette/requests.py
Expand Up @@ -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


Expand Down Expand Up @@ -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")


Expand Down

0 comments on commit fcc4c70

Please sign in to comment.