Skip to content

Commit

Permalink
Upgrade ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaugustin committed Jan 10, 2025
1 parent e6d0ea1 commit 916f841
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/websockets/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)


Expand Down
3 changes: 1 addition & 2 deletions src/websockets/http11.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/websockets/legacy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)


Expand Down
6 changes: 2 additions & 4 deletions src/websockets/sync/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions tests/asyncio/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions tests/sync/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)


Expand Down

0 comments on commit 916f841

Please sign in to comment.