Skip to content

Commit

Permalink
Make mypy happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaugustin committed Aug 3, 2024
1 parent d26bac4 commit d271022
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/websockets/legacy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ async def handler(self) -> None:
elif isinstance(exc, InvalidHandshake):
if self.debug:
self.logger.debug("! invalid handshake", exc_info=True)
exc_str = f"{exc}"
while exc.__cause__ is not None:
exc = exc.__cause__
exc_str += f"; {exc}"
exc_chain = cast(BaseException, exc)
exc_str = f"{exc_chain}"
while exc_chain.__cause__ is not None:
exc_chain = exc_chain.__cause__
exc_str += f"; {exc_chain}"
status, headers, body = (
http.HTTPStatus.BAD_REQUEST,
Headers(),
Expand Down
9 changes: 5 additions & 4 deletions src/websockets/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ def accept(self, request: Request) -> Response:
self.handshake_exc = exc
if self.debug:
self.logger.debug("! invalid handshake", exc_info=True)
exc_str = f"{exc}"
while exc.__cause__ is not None:
exc = exc.__cause__
exc_str += f"; {exc}"
exc_chain = cast(BaseException, exc)
exc_str = f"{exc_chain}"
while exc_chain.__cause__ is not None:
exc_chain = exc_chain.__cause__
exc_str += f"; {exc_chain}"
return self.reject(
http.HTTPStatus.BAD_REQUEST,
f"Failed to open a WebSocket connection: {exc_str}.\n",
Expand Down

0 comments on commit d271022

Please sign in to comment.