Skip to content

Commit

Permalink
fix WebSocketResponse._compress typing
Browse files Browse the repository at this point in the history
  • Loading branch information
derlih committed Jan 18, 2021
1 parent 52db00f commit 7a8b193
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions aiohttp/web_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __init__(
if heartbeat is not None:
self._pong_heartbeat = heartbeat / 2.0
self._pong_response_cb: Optional[asyncio.TimerHandle] = None
self._compress = compress
self._compress = int(compress)
self._max_msg_size = max_msg_size

def _cancel_heartbeat(self) -> None:
Expand Down Expand Up @@ -167,7 +167,7 @@ async def prepare(self, request: BaseRequest) -> AbstractStreamWriter:

def _handshake(
self, request: BaseRequest
) -> Tuple["CIMultiDict[str]", Optional[str], bool, bool]:
) -> Tuple["CIMultiDict[str]", Optional[str], int, bool]:
headers = request.headers
if "websocket" != headers.get(hdrs.UPGRADE, "").lower().strip():
raise HTTPBadRequest(
Expand Down Expand Up @@ -246,7 +246,7 @@ def _handshake(
return (
response_headers,
protocol,
compress, # type: ignore[return-value]
compress,
notakeover,
)

Expand Down Expand Up @@ -279,7 +279,9 @@ def _post_start(
assert loop is not None
self._reader = FlowControlDataQueue(request._protocol, 2 ** 16, loop=loop)
request.protocol.set_parser(
WebSocketReader(self._reader, self._max_msg_size, compress=self._compress)
WebSocketReader(
self._reader, self._max_msg_size, compress=bool(self._compress)
)
)
# disable HTTP keepalive for WebSocket
request.protocol.keep_alive(False)
Expand Down Expand Up @@ -307,7 +309,7 @@ def ws_protocol(self) -> Optional[str]:
return self._ws_protocol

@property
def compress(self) -> bool:
def compress(self) -> int:
return self._compress

def exception(self) -> Optional[BaseException]:
Expand Down

0 comments on commit 7a8b193

Please sign in to comment.