From 916f841815070a0374434b13b9c91829a7e7a522 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 10 Jan 2025 22:32:44 +0100 Subject: [PATCH] Upgrade ruff. --- src/websockets/exceptions.py | 3 +-- src/websockets/http11.py | 3 +-- src/websockets/legacy/exceptions.py | 4 +--- src/websockets/sync/connection.py | 6 ++---- tests/asyncio/test_server.py | 3 +-- tests/sync/test_server.py | 3 +-- tests/test_client.py | 3 +-- 7 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/websockets/exceptions.py b/src/websockets/exceptions.py index 81fbb1ef..73b24deb 100644 --- a/src/websockets/exceptions.py +++ b/src/websockets/exceptions.py @@ -204,8 +204,7 @@ def __init__(self, response: http11.Response) -> None: def __str__(self) -> str: return ( - "server rejected WebSocket connection: " - f"HTTP {self.response.status_code:d}" + f"server rejected WebSocket connection: HTTP {self.response.status_code:d}" ) diff --git a/src/websockets/http11.py b/src/websockets/http11.py index 396a43f0..49d7b9a4 100644 --- a/src/websockets/http11.py +++ b/src/websockets/http11.py @@ -94,8 +94,7 @@ class Request: @property def exception(self) -> Exception | None: # pragma: no cover warnings.warn( # deprecated in 10.3 - 2022-04-17 - "Request.exception is deprecated; " - "use ServerProtocol.handshake_exc instead", + "Request.exception is deprecated; use ServerProtocol.handshake_exc instead", DeprecationWarning, ) return self._exception diff --git a/src/websockets/legacy/exceptions.py b/src/websockets/legacy/exceptions.py index 78fb696f..29a2525b 100644 --- a/src/websockets/legacy/exceptions.py +++ b/src/websockets/legacy/exceptions.py @@ -52,9 +52,7 @@ def __init__( def __str__(self) -> str: return ( - f"HTTP {self.status:d}, " - f"{len(self.headers)} headers, " - f"{len(self.body)} bytes" + f"HTTP {self.status:d}, {len(self.headers)} headers, {len(self.body)} bytes" ) diff --git a/src/websockets/sync/connection.py b/src/websockets/sync/connection.py index d8dbf140..60be245b 100644 --- a/src/websockets/sync/connection.py +++ b/src/websockets/sync/connection.py @@ -412,8 +412,7 @@ def send( with self.send_context(): if self.send_in_progress: raise ConcurrencyError( - "cannot call send while another thread " - "is already running send" + "cannot call send while another thread is already running send" ) if text is False: self.protocol.send_binary(message.encode()) @@ -424,8 +423,7 @@ def send( with self.send_context(): if self.send_in_progress: raise ConcurrencyError( - "cannot call send while another thread " - "is already running send" + "cannot call send while another thread is already running send" ) if text is True: self.protocol.send_text(message) diff --git a/tests/asyncio/test_server.py b/tests/asyncio/test_server.py index 83885fab..edad52da 100644 --- a/tests/asyncio/test_server.py +++ b/tests/asyncio/test_server.py @@ -59,8 +59,7 @@ async def test_connection_handler_raises_exception(self): await client.recv() self.assertEqual( str(raised.exception), - "received 1011 (internal error); " - "then sent 1011 (internal error)", + "received 1011 (internal error); then sent 1011 (internal error)", ) async def test_existing_socket(self): diff --git a/tests/sync/test_server.py b/tests/sync/test_server.py index 9a267643..bb2ebae1 100644 --- a/tests/sync/test_server.py +++ b/tests/sync/test_server.py @@ -58,8 +58,7 @@ def test_connection_handler_raises_exception(self): client.recv() self.assertEqual( str(raised.exception), - "received 1011 (internal error); " - "then sent 1011 (internal error)", + "received 1011 (internal error); then sent 1011 (internal error)", ) def test_existing_socket(self): diff --git a/tests/test_client.py b/tests/test_client.py index 9f3ab09b..fc9f2ec9 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -638,8 +638,7 @@ def test_multiple_subprotocols_accepted(self): self.assertHandshakeError( client, InvalidHandshake, - "invalid Sec-WebSocket-Protocol header: " - "multiple values: superchat, chat", + "invalid Sec-WebSocket-Protocol header: multiple values: superchat, chat", )