From 72aac67a8294fb072c6bda21bc5091e2143b0a54 Mon Sep 17 00:00:00 2001 From: taras Date: Fri, 13 Sep 2024 01:30:26 +0200 Subject: [PATCH] Fix lint warnings --- examples/echo_client_benchmark.py | 16 ++++++++-------- examples/echo_server.py | 1 - examples/readme_client.py | 2 +- tests/test_basics.py | 2 -- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/examples/echo_client_benchmark.py b/examples/echo_client_benchmark.py index bf169e1..03fe376 100644 --- a/examples/echo_client_benchmark.py +++ b/examples/echo_client_benchmark.py @@ -5,8 +5,7 @@ import subprocess from logging import getLogger -from ssl import SSLContext -from typing import List, Dict, Tuple +from typing import List, Dict import numpy as np import websockets @@ -35,6 +34,7 @@ def create_client_ssl_context(): async def picows_main(endpoint: str, msg: bytes, duration: int, ssl_context): cl_type = "plain" if ssl_context is None else "ssl" print(f"Run picows python {cl_type} client") + class PicowsClientListener(WSListener): def __init__(self): super().__init__() @@ -69,7 +69,7 @@ async def websockets_main(endpoint: str, msg: bytes, duration: int, ssl_context) start_time = time() cnt = 0 while True: - reply = await websocket.recv() + await websocket.recv() cnt += 1 if time() - start_time >= duration: break @@ -163,12 +163,12 @@ async def aiohttp_main(url: str, data: bytes, duration: int, ssl_context): try: from examples.echo_client_cython import picows_main_cython if not args.picows_ssl_only: - print(f"Run picows cython plain client") + print("Run picows cython plain client") rps = asyncio.run(picows_main_cython(plain_url, msg, duration, None)) RPS["plain"].append(rps) if not args.picows_plain_only: - print(f"Run picows cython ssl client") + print("Run picows cython ssl client") rps = asyncio.run(picows_main_cython(ssl_url, msg, duration, ssl_context)) RPS["ssl"].append(rps) @@ -177,7 +177,7 @@ async def aiohttp_main(url: str, data: bytes, duration: int, ssl_context): pass if not args.picows_plain_only and not args.picows_ssl_only and args.boost_client is not None: - print(f"Run boost.beast plain client") + print("Run boost.beast plain client") pr = subprocess.run([args.boost_client, b"0", args.host.encode(), args.plain_port.encode(), @@ -186,7 +186,7 @@ async def aiohttp_main(url: str, data: bytes, duration: int, ssl_context): _, rps = pr.stdout.split(b":", 2) RPS["plain"].append(int(rps.decode())) - print(f"Run boost.beast ssl client") + print("Run boost.beast ssl client") pr = subprocess.run([args.boost_client, b"1", args.host.encode(), args.ssl_port.encode(), @@ -194,7 +194,7 @@ async def aiohttp_main(url: str, data: bytes, duration: int, ssl_context): shell=False, check=True, capture_output=True) name, rps = pr.stdout.split(b":", 2) RPS["ssl"].append(int(rps.decode())) - NAMES.append(f"c++ boost.beast") + NAMES.append("c++ boost.beast") if args.picows_plain_only or args.picows_ssl_only: exit() diff --git a/examples/echo_server.py b/examples/echo_server.py index 43fcdec..5a4e984 100644 --- a/examples/echo_server.py +++ b/examples/echo_server.py @@ -3,7 +3,6 @@ import pathlib import ssl from logging import getLogger, INFO, basicConfig -from ssl import SSLContext from picows import WSFrame, WSTransport, ws_create_server, WSListener, WSMsgType, WSUpgradeRequest diff --git a/examples/readme_client.py b/examples/readme_client.py index 11b55f6..4dd540e 100644 --- a/examples/readme_client.py +++ b/examples/readme_client.py @@ -21,4 +21,4 @@ async def main(url): if __name__ == '__main__': asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) - asyncio.run(main("ws://127.0.0.1:9001")) \ No newline at end of file + asyncio.run(main("ws://127.0.0.1:9001")) diff --git a/tests/test_basics.py b/tests/test_basics.py index 2ca157a..7f1a072 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -8,7 +8,6 @@ import picows import pytest import async_timeout -import os TIMEOUT = 0.5 @@ -291,7 +290,6 @@ class ServerClientListener(picows.WSListener): def on_ws_connected(self, transport: picows.WSTransport): raise RuntimeError("exception from on_ws_connected") - server = await picows.ws_create_server(lambda _: ServerClientListener(), "127.0.0.1", 0) async with ServerAsyncContext(server):