Skip to content

Commit

Permalink
Add type: ignore for aiofiles to make mypy happier (#1072)
Browse files Browse the repository at this point in the history
* Add type: ignore to make mypy happier

* Tentatively ignore type checking failure until the following patch gets merged

python/typeshed#4650
  • Loading branch information
moriyoshi committed Oct 14, 2020
1 parent c08aefc commit 192ac4e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions starlette/responses.py
Expand Up @@ -22,8 +22,8 @@
import aiofiles
from aiofiles.os import stat as aio_stat
except ImportError: # pragma: nocover
aiofiles = None
aio_stat = None
aiofiles = None # type: ignore
aio_stat = None # type: ignore

try:
import ujson
Expand Down Expand Up @@ -312,7 +312,10 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
if self.send_header_only:
await send({"type": "http.response.body", "body": b"", "more_body": False})
else:
async with aiofiles.open(self.path, mode="rb") as file:
# Tentatively ignoring type checking failure to work around the wrong type
# definitions for aiofile that come with typeshed. See
# https://github.com/python/typeshed/pull/4650
async with aiofiles.open(self.path, mode="rb") as file: # type: ignore
more_body = True
while more_body:
chunk = await file.read(self.chunk_size)
Expand Down

0 comments on commit 192ac4e

Please sign in to comment.