From: Daniele Varrazzo Date: Sun, 1 Oct 2023 02:25:05 +0000 (+0200) Subject: chore: drop Python 3.7 support X-Git-Tag: pool-3.2.0~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=02dfd084fc3afa74e6caff42055066f13c0ba69d;p=thirdparty%2Fpsycopg.git chore: drop Python 3.7 support Also drop from the test grid PostgreSQL 10, now unsupported. --- diff --git a/.github/workflows/3rd-party-tests.yml b/.github/workflows/3rd-party-tests.yml index 22e3e06d4..0058e431b 100644 --- a/.github/workflows/3rd-party-tests.yml +++ b/.github/workflows/3rd-party-tests.yml @@ -26,7 +26,7 @@ jobs: matrix: python-version: - "3.11" - - "3.7" + - "3.8" sqlalchemy_label: # what version of sqlalchemy to download is defined in the "include" section below, # in the variable pip_sqlalchemy diff --git a/.github/workflows/packages-bin.yml b/.github/workflows/packages-bin.yml index 123c75cb1..975fe4c5a 100644 --- a/.github/workflows/packages-bin.yml +++ b/.github/workflows/packages-bin.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: arch: [x86_64, i686, ppc64le, aarch64] - pyver: [cp37, cp38, cp39, cp310, cp311, cp312] + pyver: [cp38, cp39, cp310, cp311, cp312] platform: [manylinux, musllinux] steps: @@ -101,7 +101,7 @@ jobs: matrix: # These archs require an Apple M1 runner: [arm64, universal2] arch: [x86_64] - pyver: [cp37, cp38, cp39, cp310, cp311, cp312] + pyver: [cp38, cp39, cp310, cp311, cp312] steps: - uses: actions/checkout@v3 @@ -144,7 +144,7 @@ jobs: matrix: # Might want to add win32, untested at the moment. arch: [win_amd64] - pyver: [cp37, cp38, cp39, cp310, cp311, cp312] + pyver: [cp38, cp39, cp310, cp311, cp312] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c89ff1f24..690c9e98e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,19 +26,17 @@ jobs: matrix: include: # Test different combinations of Python, Postgres, libpq. - - {impl: python, python: "3.7", postgres: "postgres:11", libpq: newest} - - {impl: python, python: "3.8", postgres: "postgres:10"} + - {impl: python, python: "3.8", postgres: "postgres:11", libpq: newest} - {impl: python, python: "3.9", postgres: "postgres:13"} - {impl: python, python: "3.10", postgres: "postgres:14"} - {impl: python, python: "3.11", postgres: "postgres:15", libpq: master} - {impl: python, python: "3.12", postgres: "postgres:16", libpq: oldest} - - {impl: c, python: "3.7", postgres: "postgres:16", libpq: newest} - - {impl: c, python: "3.8", postgres: "postgres:14", libpq: master} - - {impl: c, python: "3.9", postgres: "postgres:15"} - - {impl: c, python: "3.10", postgres: "postgres:13"} + - {impl: c, python: "3.8", postgres: "postgres:16", libpq: newest} + - {impl: c, python: "3.9", postgres: "postgres:14", libpq: master} + - {impl: c, python: "3.10", postgres: "postgres:15"} - {impl: c, python: "3.11", postgres: "postgres:12", libpq: oldest} - - {impl: c, python: "3.12", postgres: "postgres:10", libpq: newest} + - {impl: c, python: "3.12", postgres: "postgres:11", libpq: newest} - {impl: python, python: "3.9", ext: dns, postgres: "postgres:14"} - {impl: python, python: "3.9", ext: postgis, postgres: "postgis/postgis"} @@ -46,7 +44,7 @@ jobs: - {impl: c, python: "3.11", ext: numpy, postgres: "postgres:15"} # Test with minimum dependencies versions - - {impl: c, python: "3.7", ext: min, postgres: "postgres:15"} + - {impl: c, python: "3.8", ext: min, postgres: "postgres:15"} env: PSYCOPG_IMPL: ${{ matrix.impl }} @@ -119,13 +117,11 @@ jobs: fail-fast: false matrix: include: - - {impl: python, python: "3.7"} - {impl: python, python: "3.8"} - {impl: python, python: "3.9"} - {impl: python, python: "3.10"} - {impl: python, python: "3.11"} - {impl: python, python: "3.12"} - - {impl: c, python: "3.7"} - {impl: c, python: "3.8"} - {impl: c, python: "3.9"} - {impl: c, python: "3.10"} @@ -176,13 +172,11 @@ jobs: fail-fast: false matrix: include: - - {impl: python, python: "3.7"} - {impl: python, python: "3.8"} - {impl: python, python: "3.9"} - {impl: python, python: "3.10"} - {impl: python, python: "3.11"} - {impl: python, python: "3.12"} - - {impl: c, python: "3.7"} - {impl: c, python: "3.8"} - {impl: c, python: "3.9"} - {impl: c, python: "3.10"} diff --git a/docs/basic/install.rst b/docs/basic/install.rst index 120c08f4a..d0613f13a 100644 --- a/docs/basic/install.rst +++ b/docs/basic/install.rst @@ -19,9 +19,10 @@ Supported systems The Psycopg version documented here has *official and tested* support for: -- Python: from version 3.7 to 3.12 +- Python: from version 3.8 to 3.12 - Python 3.6 supported before Psycopg 3.1 + - Python 3.7 supported before Psycopg 3.2 - PostgreSQL: from version 10 to 16 - OS: Linux, macOS, Windows diff --git a/psycopg/psycopg/_compat.py b/psycopg/psycopg/_compat.py index 5c8e87cdb..d496817ad 100644 --- a/psycopg/psycopg/_compat.py +++ b/psycopg/psycopg/_compat.py @@ -5,38 +5,6 @@ compatibility functions for different Python versions # Copyright (C) 2021 The Psycopg Team import sys -import asyncio -from typing import Any, Awaitable, Generator, Optional, Sequence, Union, TypeVar - -# NOTE: TypeAlias cannot be exported by this module, as pyright special-cases it. -# For this raisin it must be imported directly from typing_extension where used. -# See https://github.com/microsoft/pyright/issues/4197 -from typing_extensions import TypeAlias - -if sys.version_info >= (3, 8): - from typing import Protocol -else: - from typing_extensions import Protocol - -T = TypeVar("T") -FutureT: TypeAlias = Union["asyncio.Future[T]", Generator[Any, None, T], Awaitable[T]] - -if sys.version_info >= (3, 8): - create_task = asyncio.create_task - from math import prod - -else: - - def create_task( - coro: FutureT[T], name: Optional[str] = None - ) -> "asyncio.Future[T]": - return asyncio.create_task(coro) - - from functools import reduce - - def prod(seq: Sequence[int]) -> int: - return reduce(int.__mul__, seq, 1) - if sys.version_info >= (3, 9): from zoneinfo import ZoneInfo @@ -59,21 +27,12 @@ if sys.version_info >= (3, 11): else: from typing_extensions import LiteralString, assert_type -if sys.version_info < (3, 8): - import importlib_metadata as metadata -else: - from importlib import metadata - __all__ = [ "Counter", "Deque", "LiteralString", - "Protocol", "TypeGuard", "ZoneInfo", "assert_type", "cache", - "create_task", - "prod", - "metadata", ] diff --git a/psycopg/psycopg/_struct.py b/psycopg/psycopg/_struct.py index 28a608447..bce427c80 100644 --- a/psycopg/psycopg/_struct.py +++ b/psycopg/psycopg/_struct.py @@ -5,12 +5,11 @@ Utility functions to deal with binary structs. # Copyright (C) 2020 The Psycopg Team import struct -from typing import Callable, cast, Optional, Tuple +from typing import Callable, cast, Optional, Protocol, Tuple from typing_extensions import TypeAlias from .abc import Buffer from . import errors as e -from ._compat import Protocol PackInt: TypeAlias = Callable[[int], bytes] UnpackInt: TypeAlias = Callable[[Buffer], Tuple[int]] diff --git a/psycopg/psycopg/abc.py b/psycopg/psycopg/abc.py index 0cf1a7511..0ee2037ac 100644 --- a/psycopg/psycopg/abc.py +++ b/psycopg/psycopg/abc.py @@ -5,13 +5,13 @@ Protocol objects representing different implementations of the same classes. # Copyright (C) 2020 The Psycopg Team from typing import Any, Callable, Generator, Mapping -from typing import List, Optional, Sequence, Tuple, TypeVar, Union +from typing import List, Optional, Protocol, Sequence, Tuple, TypeVar, Union from typing import TYPE_CHECKING from typing_extensions import TypeAlias from . import pq from ._enums import PyFormat as PyFormat -from ._compat import Protocol, LiteralString +from ._compat import LiteralString if TYPE_CHECKING: from . import sql diff --git a/psycopg/psycopg/copy.py b/psycopg/psycopg/copy.py index de1270c55..d52e9b93d 100644 --- a/psycopg/psycopg/copy.py +++ b/psycopg/psycopg/copy.py @@ -18,7 +18,6 @@ from . import pq from . import adapt from . import errors as e from .abc import Buffer, ConnectionType, PQGen, Transformer -from ._compat import create_task from .pq.misc import connection_summary from ._cmodule import _psycopg from ._encodings import pgconn_encoding @@ -634,7 +633,7 @@ class AsyncQueuedLibpqWriter(AsyncLibpqWriter): async def write(self, data: Buffer) -> None: if not self._worker: - self._worker = create_task(self.worker()) + self._worker = asyncio.create_task(self.worker()) if len(data) <= MAX_BUFFER_SIZE: # Most used path: we don't need to split the buffer in smaller diff --git a/psycopg/psycopg/pq/abc.py b/psycopg/psycopg/pq/abc.py index e8ece59f6..3a76d56c0 100644 --- a/psycopg/psycopg/pq/abc.py +++ b/psycopg/psycopg/pq/abc.py @@ -4,12 +4,11 @@ Protocol objects to represent objects exposed by different pq implementations. # Copyright (C) 2020 The Psycopg Team -from typing import Any, Callable, List, Optional, Sequence, Tuple +from typing import Any, Callable, List, Optional, Protocol, Sequence, Tuple from typing import Union, TYPE_CHECKING from typing_extensions import TypeAlias from ._enums import Format, Trace -from .._compat import Protocol if TYPE_CHECKING: from .misc import PGnotify, ConninfoOption, PGresAttDesc diff --git a/psycopg/psycopg/rows.py b/psycopg/psycopg/rows.py index 2b240f7fb..5655a43dd 100644 --- a/psycopg/psycopg/rows.py +++ b/psycopg/psycopg/rows.py @@ -6,13 +6,12 @@ psycopg row factories import functools from typing import Any, Callable, Dict, List, Optional, NamedTuple, NoReturn -from typing import TYPE_CHECKING, Sequence, Tuple, Type, TypeVar +from typing import TYPE_CHECKING, Protocol, Sequence, Tuple, Type, TypeVar from collections import namedtuple from typing_extensions import TypeAlias from . import pq from . import errors as e -from ._compat import Protocol from ._encodings import _as_python_identifier if TYPE_CHECKING: diff --git a/psycopg/psycopg/types/array.py b/psycopg/psycopg/types/array.py index e75725aa7..3a8b1328e 100644 --- a/psycopg/psycopg/types/array.py +++ b/psycopg/psycopg/types/array.py @@ -6,6 +6,7 @@ Adapters for arrays import re import struct +from math import prod from typing import Any, cast, Callable, List, Optional, Pattern, Set, Tuple, Type from .. import pq @@ -14,7 +15,7 @@ from .. import postgres from ..abc import AdaptContext, Buffer, Dumper, DumperKey, NoneType, Loader, Transformer from ..adapt import RecursiveDumper, RecursiveLoader, PyFormat from .._oids import TEXT_OID, INVALID_OID, TEXT_ARRAY_OID -from .._compat import cache, prod +from .._compat import cache from .._struct import pack_len, unpack_len from .._cmodule import _psycopg from .._typeinfo import TypeInfo diff --git a/psycopg/psycopg/version.py b/psycopg/psycopg/version.py index 3b2e07527..b6c68c2b9 100644 --- a/psycopg/psycopg/version.py +++ b/psycopg/psycopg/version.py @@ -4,7 +4,7 @@ psycopg distribution version file. # Copyright (C) 2020 The Psycopg Team -from ._compat import metadata +from importlib import metadata try: __version__ = metadata.version("psycopg") diff --git a/psycopg/setup.cfg b/psycopg/setup.cfg index 9af8c5783..bdffb04f7 100644 --- a/psycopg/setup.cfg +++ b/psycopg/setup.cfg @@ -33,7 +33,6 @@ classifiers = Operating System :: Microsoft :: Windows Operating System :: POSIX Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 @@ -49,14 +48,13 @@ long_description_content_type = text/x-rst license_files = LICENSE.txt [options] -python_requires = >= 3.7 +python_requires = >= 3.8 packages = find: zip_safe = False install_requires = backports.zoneinfo >= 0.2.0; python_version < "3.9" typing-extensions >= 4.2 tzdata; sys_platform == "win32" - importlib-metadata >= 1.4, < 6.8; python_version < "3.8" [options.extras_require] c = diff --git a/psycopg_c/psycopg_c/_compat.py b/psycopg_c/psycopg_c/_compat.py deleted file mode 100644 index 16992cbfa..000000000 --- a/psycopg_c/psycopg_c/_compat.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -compatibility functions for different Python versions -""" - -# Copyright (C) 2021 The Psycopg Team - -import sys - -if sys.version_info < (3, 8): - import importlib_metadata as metadata -else: - from importlib import metadata - - -__all__ = ["metadata"] diff --git a/psycopg_c/psycopg_c/version.py b/psycopg_c/psycopg_c/version.py index 1da39db1f..47bdfbce3 100644 --- a/psycopg_c/psycopg_c/version.py +++ b/psycopg_c/psycopg_c/version.py @@ -4,7 +4,7 @@ psycopg-c distribution version file. # Copyright (C) 2020 The Psycopg Team -from ._compat import metadata +from importlib import metadata try: __version__ = metadata.version("psycopg-c") diff --git a/psycopg_c/setup.cfg b/psycopg_c/setup.cfg index fde807e94..730596f4d 100644 --- a/psycopg_c/setup.cfg +++ b/psycopg_c/setup.cfg @@ -23,7 +23,6 @@ classifiers = Operating System :: Microsoft :: Windows Operating System :: POSIX Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 @@ -39,11 +38,9 @@ long_description_content_type = text/x-rst license_files = LICENSE.txt [options] -python_requires = >= 3.7 +python_requires = >= 3.8 packages = find: zip_safe = False -install_requires = - importlib-metadata >= 1.4, < 6.8; python_version < "3.8" [options.package_data] # NOTE: do not include .pyx files: they shouldn't be in the sdist diff --git a/psycopg_pool/psycopg_pool/_compat.py b/psycopg_pool/psycopg_pool/_compat.py index 2ddbcb158..c3e27f02b 100644 --- a/psycopg_pool/psycopg_pool/_compat.py +++ b/psycopg_pool/psycopg_pool/_compat.py @@ -5,44 +5,18 @@ compatibility functions for different Python versions # Copyright (C) 2021 The Psycopg Team import sys -import asyncio -from typing import Any, Awaitable, Generator, Optional, Union, Type, TypeVar -from typing_extensions import TypeAlias +from typing import Type import psycopg.errors as e -T = TypeVar("T") -FutureT: TypeAlias = Union["asyncio.Future[T]", Generator[Any, None, T], Awaitable[T]] - -if sys.version_info >= (3, 8): - create_task = asyncio.create_task - Task = asyncio.Task - -else: - - def create_task( - coro: FutureT[T], name: Optional[str] = None - ) -> "asyncio.Future[T]": - return asyncio.create_task(coro) - - Task = asyncio.Future - if sys.version_info >= (3, 9): from collections import Counter, deque as Deque else: from typing import Counter, Deque -if sys.version_info < (3, 8): - import importlib_metadata as metadata -else: - from importlib import metadata - __all__ = [ "Counter", "Deque", - "Task", - "create_task", - "metadata", ] # Workaround for psycopg < 3.0.8. diff --git a/psycopg_pool/psycopg_pool/pool_async.py b/psycopg_pool/psycopg_pool/pool_async.py index 9ee8e8554..76a2cf489 100644 --- a/psycopg_pool/psycopg_pool/pool_async.py +++ b/psycopg_pool/psycopg_pool/pool_async.py @@ -12,6 +12,7 @@ from types import TracebackType from typing import Any, AsyncIterator, Awaitable, Callable, cast, Generic from typing import Dict, List, Optional, overload, Sequence, Type, TypeVar, Union from typing_extensions import TypeAlias +from asyncio import create_task, Task from weakref import ref from contextlib import asynccontextmanager @@ -23,7 +24,7 @@ from psycopg.rows import TupleRow from .base import ConnectionAttempt, BasePool from .sched import AsyncScheduler from .errors import PoolClosed, PoolTimeout, TooManyRequests -from ._compat import Task, create_task, Deque +from ._compat import Deque logger = logging.getLogger("psycopg.pool") diff --git a/psycopg_pool/psycopg_pool/version.py b/psycopg_pool/psycopg_pool/version.py index 628f16a1a..765e03605 100644 --- a/psycopg_pool/psycopg_pool/version.py +++ b/psycopg_pool/psycopg_pool/version.py @@ -4,7 +4,7 @@ psycopg pool version file. # Copyright (C) 2021 The Psycopg Team -from ._compat import metadata +from importlib import metadata try: __version__ = metadata.version("psycopg-pool") diff --git a/psycopg_pool/setup.cfg b/psycopg_pool/setup.cfg index 43378bd49..f08727f45 100644 --- a/psycopg_pool/setup.cfg +++ b/psycopg_pool/setup.cfg @@ -27,7 +27,6 @@ classifiers = Operating System :: Microsoft :: Windows Operating System :: POSIX Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 @@ -43,12 +42,11 @@ long_description_content_type = text/x-rst license_files = LICENSE.txt [options] -python_requires = >= 3.7 +python_requires = >= 3.8 packages = find: zip_safe = False install_requires = typing-extensions >= 3.10 - importlib-metadata >= 1.4, < 6.8; python_version < "3.8" [options.package_data] psycopg_pool = py.typed diff --git a/tests/README.rst b/tests/README.rst index 63c72382a..b99be8322 100644 --- a/tests/README.rst +++ b/tests/README.rst @@ -74,7 +74,7 @@ a set of env vars working for your setup:: $ docker run -ti --rm --volume `pwd`:/src --workdir /src \ -e PSYCOPG_TEST_DSN -e PGHOST=172.17.0.1 -e PGUSER=`whoami` \ - python:3.7 bash + python:3.8 bash # pip install -e "./psycopg[test]" ./psycopg_pool ./psycopg_c # pytest diff --git a/tests/conftest.py b/tests/conftest.py index e674f6e76..ab3295448 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -69,7 +69,7 @@ def pytest_sessionstart(session): asyncio_options: Dict[str, Any] = {} -if sys.platform == "win32" and sys.version_info >= (3, 8): +if sys.platform == "win32": asyncio_options["policy"] = asyncio.WindowsSelectorEventLoopPolicy() diff --git a/tests/crdb/test_connection_async.py b/tests/crdb/test_connection_async.py index 9cd73ddd7..9b224e41f 100644 --- a/tests/crdb/test_connection_async.py +++ b/tests/crdb/test_connection_async.py @@ -4,7 +4,6 @@ import asyncio import psycopg.crdb from psycopg import errors as e from psycopg.crdb import AsyncCrdbConnection -from psycopg._compat import create_task import pytest @@ -74,7 +73,7 @@ async def test_identify_closure(aconn_cls, dsn): await asyncio.sleep(0.2) await conn2.execute("cancel session %s", [session_id]) - t = create_task(closer()) + t = asyncio.create_task(closer()) t0 = time.time() try: with pytest.raises(psycopg.OperationalError): diff --git a/tests/crdb/test_cursor_async.py b/tests/crdb/test_cursor_async.py index 2472c37f2..c643a40c3 100644 --- a/tests/crdb/test_cursor_async.py +++ b/tests/crdb/test_cursor_async.py @@ -6,7 +6,6 @@ from asyncio.queues import Queue import pytest from psycopg import pq, errors as e from psycopg.rows import namedtuple_row -from psycopg._compat import create_task from .test_cursor import testfeed @@ -36,7 +35,7 @@ async def test_changefeed(aconn_cls, dsn, aconn, testfeed, fmt_out): except Exception as ex: q.put_nowait(ex) - t = create_task(worker()) + t = asyncio.create_task(worker()) cur = aconn.cursor() await cur.execute(f"insert into {testfeed} (data) values ('hello') returning id") diff --git a/tests/pool/test_null_pool_async.py b/tests/pool/test_null_pool_async.py index 47b0c8820..55708e50a 100644 --- a/tests/pool/test_null_pool_async.py +++ b/tests/pool/test_null_pool_async.py @@ -2,6 +2,7 @@ import asyncio import logging from time import time from typing import Any, Dict, List, Tuple +from asyncio import create_task import pytest from packaging.version import parse as ver # noqa: F401 # used in skipif @@ -9,7 +10,7 @@ from packaging.version import parse as ver # noqa: F401 # used in skipif import psycopg from psycopg.pq import TransactionStatus from psycopg.rows import class_row, Row, TupleRow -from psycopg._compat import assert_type, create_task +from psycopg._compat import assert_type from .test_pool_async import delay_connection, ensure_waiting pytestmark = [pytest.mark.anyio] @@ -901,7 +902,6 @@ async def test_stats_connect(dsn, proxy, monkeypatch): assert 200 <= stats["connections_ms"] < 300 -@pytest.mark.skipif("sys.version_info < (3, 8)", reason="asyncio bug") async def test_cancellation_in_queue(dsn): # https://github.com/psycopg/psycopg/issues/509 @@ -949,7 +949,6 @@ async def test_cancellation_in_queue(dsn): pytest.fail("no client got in the queue") [task.cancel() for task in reversed(tasks)] - # Python 3.7 hangs on this statement, instead of timing out or returning await asyncio.wait_for(asyncio.gather(*tasks, return_exceptions=True), 1.0) stats = p.get_stats() diff --git a/tests/pool/test_pool_async.py b/tests/pool/test_pool_async.py index 31861df91..0726f35c7 100644 --- a/tests/pool/test_pool_async.py +++ b/tests/pool/test_pool_async.py @@ -2,13 +2,14 @@ import asyncio import logging from time import time from typing import Any, Dict, List, Tuple +from asyncio import create_task import pytest import psycopg from psycopg.pq import TransactionStatus from psycopg.rows import class_row, Row, TupleRow -from psycopg._compat import assert_type, create_task, Counter +from psycopg._compat import assert_type, Counter try: import psycopg_pool as pool @@ -1263,7 +1264,6 @@ async def test_debug_deadlock(dsn): logger.setLevel(old_level) -@pytest.mark.skipif("sys.version_info < (3, 8)", reason="asyncio bug") async def test_cancellation_in_queue(dsn): # https://github.com/psycopg/psycopg/issues/509 @@ -1309,7 +1309,6 @@ async def test_cancellation_in_queue(dsn): pytest.fail("no client got in the queue") [task.cancel() for task in reversed(tasks)] - # Python 3.7 hangs on this statement, instead of timing out or returning await asyncio.wait_for(asyncio.gather(*tasks, return_exceptions=True), 1.0) stats = p.get_stats() diff --git a/tests/pool/test_sched_async.py b/tests/pool/test_sched_async.py index 82eb44276..45c94a5eb 100644 --- a/tests/pool/test_sched_async.py +++ b/tests/pool/test_sched_async.py @@ -1,12 +1,11 @@ import asyncio import logging from time import time +from asyncio import create_task from functools import partial import pytest -from psycopg._compat import create_task - try: from psycopg_pool.sched import AsyncScheduler except ImportError: diff --git a/tests/test_concurrency_async.py b/tests/test_concurrency_async.py index 017bbd79e..db97a4bf0 100644 --- a/tests/test_concurrency_async.py +++ b/tests/test_concurrency_async.py @@ -4,6 +4,7 @@ import signal import asyncio import threading import subprocess as sp +from asyncio import create_task from asyncio.queues import Queue from typing import List, Tuple @@ -11,7 +12,6 @@ import pytest import psycopg from psycopg import errors as e -from psycopg._compat import create_task @pytest.mark.slow diff --git a/tests/test_transaction_async.py b/tests/test_transaction_async.py index 921ea5a14..abe5bf063 100644 --- a/tests/test_transaction_async.py +++ b/tests/test_transaction_async.py @@ -5,7 +5,6 @@ import pytest from psycopg import Rollback from psycopg import errors as e -from psycopg._compat import create_task from .test_transaction import in_transaction, insert_row, inserted, get_exc_info from .test_transaction import ExpectedException, crdb_skip_external_observer @@ -729,11 +728,11 @@ async def test_concurrency(aconn, what): assert "transaction commit" in str(ex.value) # Start a first transaction in a task - t1 = create_task(worker(unlock=evs[0], wait_on=evs[1])) + t1 = asyncio.create_task(worker(unlock=evs[0], wait_on=evs[1])) await evs[0].wait() # Start a nested transaction in a task - t2 = create_task(worker(unlock=evs[1], wait_on=evs[2])) + t2 = asyncio.create_task(worker(unlock=evs[1], wait_on=evs[2])) # Terminate the first transaction before the second does await asyncio.gather(t1) diff --git a/tests/types/test_array.py b/tests/types/test_array.py index 1f8c0f0de..f9fb85ccb 100644 --- a/tests/types/test_array.py +++ b/tests/types/test_array.py @@ -1,4 +1,5 @@ import gc +from math import prod from typing import List, Any from decimal import Decimal @@ -9,7 +10,6 @@ from psycopg import pq from psycopg import sql from psycopg.adapt import PyFormat, Transformer, Dumper from psycopg.types import TypeInfo -from psycopg._compat import prod from psycopg.postgres import types as builtins from psycopg.types.array import register_array