Skip to content

Commit ee8aa1c

Browse files
committed
Lint; add cast for return type
1 parent ce2a152 commit ee8aa1c

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

httpcore/_async/http11.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
Optional,
99
Tuple,
1010
Type,
11-
cast,
1211
Union,
12+
cast,
1313
)
1414

1515
import h11
@@ -194,7 +194,7 @@ async def _receive_event(self, timeout: float = None) -> h11.Event:
194194
# TODO: Implement handling for paused
195195
...
196196
else:
197-
return event
197+
return cast(h11.Event, event)
198198

199199
async def _response_closed(self) -> None:
200200
async with self._state_lock:

httpcore/_sync/http11.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def handle_request(self, request: Request) -> Response:
6161
self._send_request_headers(**kwargs)
6262
with Trace("http11.send_request_body", request, kwargs) as trace:
6363
self._send_request_body(**kwargs)
64-
with Trace(
65-
"http11.receive_response_headers", request, kwargs
66-
) as trace:
64+
with Trace("http11.receive_response_headers", request, kwargs) as trace:
6765
(
6866
http_version,
6967
status,
@@ -158,12 +156,13 @@ def _receive_event(self, timeout: float = None) -> h11.Event:
158156
while True:
159157
with map_exceptions({h11.RemoteProtocolError: RemoteProtocolError}):
160158
# The h11 type signature uses a private return type
161-
event = cast(Union[h11.Event, h11.NEED_DATA, h11.PAUSED], self._h11_state.next_event())
159+
event = cast(
160+
Union[h11.Event, h11.NEED_DATA, h11.PAUSED],
161+
self._h11_state.next_event(),
162+
)
162163

163164
if event is h11.NEED_DATA:
164-
data = self._network_stream.read(
165-
self.READ_NUM_BYTES, timeout=timeout
166-
)
165+
data = self._network_stream.read(self.READ_NUM_BYTES, timeout=timeout)
167166

168167
# If we feed this case through h11 we'll raise an exception like:
169168
#
@@ -182,7 +181,7 @@ def _receive_event(self, timeout: float = None) -> h11.Event:
182181
# TODO: Implement handling for paused
183182
...
184183
else:
185-
return event
184+
return cast(h11.Event, event)
186185

187186
def _response_closed(self) -> None:
188187
with self._state_lock:

0 commit comments

Comments
 (0)