Skip to content

Commit

Permalink
Enable mypy option --warn-return-any (#612)
Browse files Browse the repository at this point in the history
* Enable mypy option `--warn-return-any`

* Remove type ignore comment
  • Loading branch information
michaeloliverx committed Nov 18, 2022
1 parent 2f1cf70 commit d7d005e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions httpcore/_async/http2.py
Expand Up @@ -342,7 +342,7 @@ async def _read_incoming_data(
self._connection_error = True
raise exc

events = self._h2_state.receive_data(data)
events: typing.List[h2.events.Event] = self._h2_state.receive_data(data)

return events

Expand Down Expand Up @@ -381,8 +381,8 @@ async def _wait_for_outgoing_flow(self, request: Request, stream_id: int) -> int
WindowUpdated frames have increased the flow rate.
https://tools.ietf.org/html/rfc7540#section-6.9
"""
local_flow = self._h2_state.local_flow_control_window(stream_id)
max_frame_size = self._h2_state.max_outbound_frame_size
local_flow: int = self._h2_state.local_flow_control_window(stream_id)
max_frame_size: int = self._h2_state.max_outbound_frame_size
flow = min(local_flow, max_frame_size)
while flow == 0:
await self._receive_events(request)
Expand Down
6 changes: 3 additions & 3 deletions httpcore/_sync/http2.py
Expand Up @@ -342,7 +342,7 @@ def _read_incoming_data(
self._connection_error = True
raise exc

events = self._h2_state.receive_data(data)
events: typing.List[h2.events.Event] = self._h2_state.receive_data(data)

return events

Expand Down Expand Up @@ -381,8 +381,8 @@ def _wait_for_outgoing_flow(self, request: Request, stream_id: int) -> int:
WindowUpdated frames have increased the flow rate.
https://tools.ietf.org/html/rfc7540#section-6.9
"""
local_flow = self._h2_state.local_flow_control_window(stream_id)
max_frame_size = self._h2_state.max_outbound_frame_size
local_flow: int = self._h2_state.local_flow_control_window(stream_id)
max_frame_size: int = self._h2_state.max_outbound_frame_size
flow = min(local_flow, max_frame_size)
while flow == 0:
self._receive_events(request)
Expand Down
3 changes: 2 additions & 1 deletion httpcore/backends/trio.py
Expand Up @@ -26,7 +26,8 @@ async def read(
exc_map = {trio.TooSlowError: ReadTimeout, trio.BrokenResourceError: ReadError}
with map_exceptions(exc_map):
with trio.fail_after(timeout_or_inf):
return await self._stream.receive_some(max_bytes=max_bytes)
data: bytes = await self._stream.receive_some(max_bytes=max_bytes)
return data

async def write(
self, buffer: bytes, timeout: typing.Optional[float] = None
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -10,6 +10,7 @@ no_implicit_optional = True
show_error_codes = True
warn_unused_ignores = True
disallow_untyped_calls = True
warn_return_any = True

[mypy-tests.*]
disallow_untyped_defs = False
Expand Down

0 comments on commit d7d005e

Please sign in to comment.