From ef3a92c8891d53cf90b1f0fa51abbe9e78bcb572 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 3 Apr 2025 12:07:46 +0100 Subject: [PATCH] chore: drop unneeded nonlocal declarations Flagged by flake8 7.2 --- tests/pool/test_pool.py | 2 -- tests/pool/test_pool_async.py | 2 -- tests/pool/test_pool_common.py | 2 -- tests/pool/test_pool_common_async.py | 2 -- tests/pool/test_pool_null.py | 2 -- tests/pool/test_pool_null_async.py | 2 -- tests/test_concurrency.py | 1 - tests/test_concurrency_async.py | 1 - tests/test_errors.py | 1 - 9 files changed, 15 deletions(-) diff --git a/tests/pool/test_pool.py b/tests/pool/test_pool.py index 076a976dc..873daff4a 100644 --- a/tests/pool/test_pool.py +++ b/tests/pool/test_pool.py @@ -948,8 +948,6 @@ def test_cancellation_in_queue(dsn): def worker(i): try: logging.info("worker %s started", i) - nonlocal got_conns - with p.connection() as conn: logging.info("worker %s got conn", i) cur = conn.execute("select 1") diff --git a/tests/pool/test_pool_async.py b/tests/pool/test_pool_async.py index aaf780994..939c3f707 100644 --- a/tests/pool/test_pool_async.py +++ b/tests/pool/test_pool_async.py @@ -950,8 +950,6 @@ async def test_cancellation_in_queue(dsn): async def worker(i): try: logging.info("worker %s started", i) - nonlocal got_conns - async with p.connection() as conn: logging.info("worker %s got conn", i) cur = await conn.execute("select 1") diff --git a/tests/pool/test_pool_common.py b/tests/pool/test_pool_common.py index 261fb195a..3c21c0980 100644 --- a/tests/pool/test_pool_common.py +++ b/tests/pool/test_pool_common.py @@ -655,8 +655,6 @@ def test_cancellation_in_queue(pool_cls, dsn): def worker(i): try: logging.info("worker %s started", i) - nonlocal got_conns - with p.connection() as conn: logging.info("worker %s got conn", i) cur = conn.execute("select 1") diff --git a/tests/pool/test_pool_common_async.py b/tests/pool/test_pool_common_async.py index 228d19aae..068064d68 100644 --- a/tests/pool/test_pool_common_async.py +++ b/tests/pool/test_pool_common_async.py @@ -665,8 +665,6 @@ async def test_cancellation_in_queue(pool_cls, dsn): async def worker(i): try: logging.info("worker %s started", i) - nonlocal got_conns - async with p.connection() as conn: logging.info("worker %s got conn", i) cur = await conn.execute("select 1") diff --git a/tests/pool/test_pool_null.py b/tests/pool/test_pool_null.py index e18e43528..9d84e4ae7 100644 --- a/tests/pool/test_pool_null.py +++ b/tests/pool/test_pool_null.py @@ -459,8 +459,6 @@ def test_cancellation_in_queue(dsn): def worker(i): try: logging.info("worker %s started", i) - nonlocal got_conns - with p.connection() as conn: logging.info("worker %s got conn", i) cur = conn.execute("select 1") diff --git a/tests/pool/test_pool_null_async.py b/tests/pool/test_pool_null_async.py index 930ad44db..1d40c6dd5 100644 --- a/tests/pool/test_pool_null_async.py +++ b/tests/pool/test_pool_null_async.py @@ -460,8 +460,6 @@ async def test_cancellation_in_queue(dsn): async def worker(i): try: logging.info("worker %s started", i) - nonlocal got_conns - async with p.connection() as conn: logging.info("worker %s got conn", i) cur = await conn.execute("select 1") diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py index 030965580..488b197c0 100644 --- a/tests/test_concurrency.py +++ b/tests/test_concurrency.py @@ -46,7 +46,6 @@ def test_commit_concurrency(conn): stop = False def committer(): - nonlocal stop while not stop: conn.commit() diff --git a/tests/test_concurrency_async.py b/tests/test_concurrency_async.py index 63b7b3f81..c69954b13 100644 --- a/tests/test_concurrency_async.py +++ b/tests/test_concurrency_async.py @@ -25,7 +25,6 @@ async def test_commit_concurrency(aconn): stop = False async def committer(): - nonlocal stop while not stop: await aconn.commit() await asyncio.sleep(0) # Allow the other worker to work diff --git a/tests/test_errors.py b/tests/test_errors.py index 8dab38fde..536cbf3e6 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -54,7 +54,6 @@ def test_diag_right_attr(pgconn, monkeypatch): checked: list[pq.DiagnosticField] = [] def check_val(self, v): - nonlocal to_check assert to_check == v checked.append(v) return None -- 2.47.2