Skip to content

Commit d271022

Browse files
committed
Make mypy happy.
1 parent d26bac4 commit d271022

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/websockets/legacy/server.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ async def handler(self) -> None:
199199
elif isinstance(exc, InvalidHandshake):
200200
if self.debug:
201201
self.logger.debug("! invalid handshake", exc_info=True)
202-
exc_str = f"{exc}"
203-
while exc.__cause__ is not None:
204-
exc = exc.__cause__
205-
exc_str += f"; {exc}"
202+
exc_chain = cast(BaseException, exc)
203+
exc_str = f"{exc_chain}"
204+
while exc_chain.__cause__ is not None:
205+
exc_chain = exc_chain.__cause__
206+
exc_str += f"; {exc_chain}"
206207
status, headers, body = (
207208
http.HTTPStatus.BAD_REQUEST,
208209
Headers(),

src/websockets/server.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,11 @@ def accept(self, request: Request) -> Response:
163163
self.handshake_exc = exc
164164
if self.debug:
165165
self.logger.debug("! invalid handshake", exc_info=True)
166-
exc_str = f"{exc}"
167-
while exc.__cause__ is not None:
168-
exc = exc.__cause__
169-
exc_str += f"; {exc}"
166+
exc_chain = cast(BaseException, exc)
167+
exc_str = f"{exc_chain}"
168+
while exc_chain.__cause__ is not None:
169+
exc_chain = exc_chain.__cause__
170+
exc_str += f"; {exc_chain}"
170171
return self.reject(
171172
http.HTTPStatus.BAD_REQUEST,
172173
f"Failed to open a WebSocket connection: {exc_str}.\n",

0 commit comments

Comments
 (0)