From 245ea40e5b6f293e7c18cb285bf7617b88d9ebd9 Mon Sep 17 00:00:00 2001 From: Leszek Hanusz Date: Tue, 30 Jun 2026 11:52:05 +0200 Subject: [PATCH] Fix flake8 unused nonlocal and global warnings (F824) --- gql/transport/file_upload.py | 1 - setup.py | 2 +- tests/test_aiohttp_websocket_graphqlws_subscription.py | 3 --- tests/test_aiohttp_websocket_subscription.py | 4 ---- tests/test_appsync_websockets.py | 1 - tests/test_graphqlws_subscription.py | 3 --- tests/test_phoenix_channel_subscription.py | 1 - tests/test_websocket_subscription.py | 4 ---- 8 files changed, 1 insertion(+), 18 deletions(-) diff --git a/gql/transport/file_upload.py b/gql/transport/file_upload.py index 8673ab60..72c7265a 100644 --- a/gql/transport/file_upload.py +++ b/gql/transport/file_upload.py @@ -89,7 +89,6 @@ def recurse_extract(path, obj): replacing any file-like objects with nulls and shunting the originals off to the side. """ - nonlocal files if isinstance(obj, list): nulled_list = [] for key, value in enumerate(obj): diff --git a/setup.py b/setup.py index c64a6dd9..25d00a84 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ dev_requires = [ "black==26.5.1", "check-manifest>=0.42,<1", - "flake8==7.1.2", + "flake8==7.3.0", "isort==6.0.1", "mypy==1.15", "sphinx>=8.1.0,<9", diff --git a/tests/test_aiohttp_websocket_graphqlws_subscription.py b/tests/test_aiohttp_websocket_graphqlws_subscription.py index e03ad8f9..497caed5 100644 --- a/tests/test_aiohttp_websocket_graphqlws_subscription.py +++ b/tests/test_aiohttp_websocket_graphqlws_subscription.py @@ -111,7 +111,6 @@ async def keepalive_coro(): async def receiving_coro(): print(" Server: receiving task started") try: - nonlocal counting_task while True: try: @@ -314,7 +313,6 @@ async def task_coro(): task = asyncio.ensure_future(task_coro()) async def cancel_task_coro(): - nonlocal task await asyncio.sleep(5.5 * COUNTING_DELAY) @@ -354,7 +352,6 @@ async def task_coro(): task = asyncio.ensure_future(task_coro()) async def close_transport_task_coro(): - nonlocal task await asyncio.sleep(5.5 * COUNTING_DELAY) diff --git a/tests/test_aiohttp_websocket_subscription.py b/tests/test_aiohttp_websocket_subscription.py index b099a4a9..658e3eff 100644 --- a/tests/test_aiohttp_websocket_subscription.py +++ b/tests/test_aiohttp_websocket_subscription.py @@ -97,7 +97,6 @@ async def server_countdown(ws): logged_messages.clear() - global WITH_KEEPALIVE try: await WebSocketServerHelper.send_connection_ack(ws) if WITH_KEEPALIVE: @@ -126,7 +125,6 @@ async def counting_coro(): counting_task = asyncio.ensure_future(counting_coro()) async def stopping_coro(): - nonlocal counting_task while True: try: @@ -305,7 +303,6 @@ async def task_coro(): task = asyncio.ensure_future(task_coro()) async def cancel_task_coro(): - nonlocal task await asyncio.sleep(11 * MS) @@ -345,7 +342,6 @@ async def task_coro(): task = asyncio.ensure_future(task_coro()) async def close_transport_task_coro(): - nonlocal task await asyncio.sleep(11 * MS) diff --git a/tests/test_appsync_websockets.py b/tests/test_appsync_websockets.py index b92da159..2103db8f 100644 --- a/tests/test_appsync_websockets.py +++ b/tests/test_appsync_websockets.py @@ -277,7 +277,6 @@ async def keepalive_coro(): async def receiving_coro(): print(" Server: receiving task started") try: - nonlocal send_message_task while True: try: diff --git a/tests/test_graphqlws_subscription.py b/tests/test_graphqlws_subscription.py index a65e4895..236a3321 100644 --- a/tests/test_graphqlws_subscription.py +++ b/tests/test_graphqlws_subscription.py @@ -111,7 +111,6 @@ async def keepalive_coro(): async def receiving_coro(): print(" Server: receiving task started") try: - nonlocal counting_task while True: try: @@ -312,7 +311,6 @@ async def task_coro(): task = asyncio.ensure_future(task_coro()) async def cancel_task_coro(): - nonlocal task await asyncio.sleep(5.5 * COUNTING_DELAY) @@ -352,7 +350,6 @@ async def task_coro(): task = asyncio.ensure_future(task_coro()) async def close_transport_task_coro(): - nonlocal task await asyncio.sleep(5.5 * COUNTING_DELAY) diff --git a/tests/test_phoenix_channel_subscription.py b/tests/test_phoenix_channel_subscription.py index ecda9c38..a54c594c 100644 --- a/tests/test_phoenix_channel_subscription.py +++ b/tests/test_phoenix_channel_subscription.py @@ -117,7 +117,6 @@ async def counting_coro(): counting_task = asyncio.ensure_future(counting_coro()) async def stopping_coro(): - nonlocal counting_task while True: result = await ws.recv() json_result = json.loads(result) diff --git a/tests/test_websocket_subscription.py b/tests/test_websocket_subscription.py index 5baa0b4e..c2f810e0 100644 --- a/tests/test_websocket_subscription.py +++ b/tests/test_websocket_subscription.py @@ -33,7 +33,6 @@ async def server_countdown(ws): logged_messages.clear() - global WITH_KEEPALIVE try: await WebSocketServerHelper.send_connection_ack(ws) if WITH_KEEPALIVE: @@ -62,7 +61,6 @@ async def counting_coro(): counting_task = asyncio.ensure_future(counting_coro()) async def stopping_coro(): - nonlocal counting_task while True: try: @@ -232,7 +230,6 @@ async def task_coro(): task = asyncio.ensure_future(task_coro()) async def cancel_task_coro(): - nonlocal task await asyncio.sleep(11 * MS) @@ -272,7 +269,6 @@ async def task_coro(): task = asyncio.ensure_future(task_coro()) async def close_transport_task_coro(): - nonlocal task await asyncio.sleep(11 * MS)