From: Daniele Varrazzo Date: Thu, 3 Apr 2025 11:07:46 +0000 (+0100) Subject: chore: drop unneeded nonlocal declarations X-Git-Tag: 3.2.7~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c67834136d3adebf4947109e297e6e82d6c2fc4;p=thirdparty%2Fpsycopg.git chore: drop unneeded nonlocal declarations Flagged by flake8 7.2 --- diff --git a/tests/pool/test_pool.py b/tests/pool/test_pool.py index cd19b7636..05aa44e4c 100644 --- a/tests/pool/test_pool.py +++ b/tests/pool/test_pool.py @@ -947,8 +947,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 580260090..f56748d42 100644 --- a/tests/pool/test_pool_async.py +++ b/tests/pool/test_pool_async.py @@ -949,8 +949,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 21a0025ba..fb2157980 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 6346628dc..87e2411d3 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