From: Daniele Varrazzo Date: Fri, 13 Oct 2023 01:35:26 +0000 (+0200) Subject: chore: use Python 3.11 to conver async to sync X-Git-Tag: pool-3.2.0~12^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bbd671e1117b721de7f15bf03dece759c5076a5e;p=thirdparty%2Fpsycopg.git chore: use Python 3.11 to conver async to sync --- diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3fea1c28f..2ad8b8c55 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - name: install packages to tests run: pip install ./psycopg[dev,test] codespell diff --git a/psycopg_pool/psycopg_pool/null_pool.py b/psycopg_pool/psycopg_pool/null_pool.py index 1ffeceae4..47643bb10 100644 --- a/psycopg_pool/psycopg_pool/null_pool.py +++ b/psycopg_pool/psycopg_pool/null_pool.py @@ -176,7 +176,7 @@ class NullConnectionPool(_BaseNullConnectionPool, ConnectionPool[CT]): Only *max_size* can be changed; *min_size* must remain 0. """ - (min_size, max_size) = self._check_size(min_size, max_size) + min_size, max_size = self._check_size(min_size, max_size) logger.info( "resizing %r to min_size=%s max_size=%s", self.name, min_size, max_size diff --git a/psycopg_pool/psycopg_pool/pool.py b/psycopg_pool/psycopg_pool/pool.py index f2fab5d26..54125fcdb 100644 --- a/psycopg_pool/psycopg_pool/pool.py +++ b/psycopg_pool/psycopg_pool/pool.py @@ -421,7 +421,7 @@ class ConnectionPool(Generic[CT], BasePool): self._sched.enter(0, None) # Stop the worker tasks - (workers, self._workers) = (self._workers[:], []) + workers, self._workers = (self._workers[:], []) for _ in workers: self.run_task(StopWorker(self)) @@ -435,7 +435,7 @@ class ConnectionPool(Generic[CT], BasePool): # Wait for the worker tasks to terminate assert self._sched_runner is not None - (sched_runner, self._sched_runner) = (self._sched_runner, None) + sched_runner, self._sched_runner = (self._sched_runner, None) gather(sched_runner, *workers, timeout=timeout) def __enter__(self: _Self) -> _Self: @@ -452,7 +452,7 @@ class ConnectionPool(Generic[CT], BasePool): def resize(self, min_size: int, max_size: Optional[int] = None) -> None: """Change the size of the pool during runtime.""" - (min_size, max_size) = self._check_size(min_size, max_size) + min_size, max_size = self._check_size(min_size, max_size) ngrow = max(0, min_size - self._min_size) diff --git a/tests/pool/test_pool_common.py b/tests/pool/test_pool_common.py index ce60ea795..a6b152b64 100644 --- a/tests/pool/test_pool_common.py +++ b/tests/pool/test_pool_common.py @@ -213,7 +213,7 @@ def test_dead_client(pool_cls, dsn): results: List[int] = [] ts = [ spawn(worker, args=(i, timeout)) - for (i, timeout) in enumerate([0.4, 0.4, 0.1, 0.4, 0.4]) + for i, timeout in enumerate([0.4, 0.4, 0.1, 0.4, 0.4]) ] gather(*ts) diff --git a/tests/test_connection.py b/tests/test_connection.py index dcc38a2bc..1ead1ba9d 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -633,7 +633,7 @@ def test_transaction_param_default(conn, param): "select current_setting(%s), current_setting(%s)", [f"transaction_{param.guc}", f"default_transaction_{param.guc}"], ) - (current, default) = cur.fetchone() + current, default = cur.fetchone() assert current == default @@ -654,7 +654,7 @@ def test_set_transaction_param_implicit(conn, param, autocommit): "select current_setting(%s), current_setting(%s)", [f"transaction_{param.guc}", f"default_transaction_{param.guc}"], ) - (pgval, default) = cur.fetchone() + pgval, default = cur.fetchone() if autocommit: assert pgval == default else: diff --git a/tests/test_cursor_common.py b/tests/test_cursor_common.py index a5090f92c..19cc31bbf 100644 --- a/tests/test_cursor_common.py +++ b/tests/test_cursor_common.py @@ -170,7 +170,7 @@ def test_query_parse_cache_size(conn): cache.cache_clear() ci = cache.cache_info() - (h0, m0) = (ci.hits, ci.misses) + h0, m0 = (ci.hits, ci.misses) tests = [ (f"select 1 -- {'x' * 3500}", (), h0, m0 + 1), (f"select 1 -- {'x' * 3500}", (), h0 + 1, m0 + 1), diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index a40035a33..c88475a2d 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -372,7 +372,7 @@ def test_executemany_trace(conn, trace): items = list(t) assert items[-1].type == "Terminate" del items[-1] - roundtrips = [k for (k, g) in groupby(items, key=attrgetter("direction"))] + roundtrips = [k for k, g in groupby(items, key=attrgetter("direction"))] assert roundtrips == ["F", "B"] assert len([i for i in items if i.type == "Sync"]) == 1 @@ -394,7 +394,7 @@ def test_executemany_trace_returning(conn, trace): items = list(t) assert items[-1].type == "Terminate" del items[-1] - roundtrips = [k for (k, g) in groupby(items, key=attrgetter("direction"))] + roundtrips = [k for k, g in groupby(items, key=attrgetter("direction"))] assert roundtrips == ["F", "B"] * 3 assert items[-2].direction == "F" # last 2 items are F B assert len([i for i in items if i.type == "Sync"]) == 1