``psycopg`` release notes
=========================
+Future releases
+---------------
+
+Psycopg 3.2.2 (unreleased)
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Drop `!TypeDef` specifications as string from public modules, as they cannot
+ be composed by users as `!typing` objects previously could (:ticket:`#860`).
+
+
Current release
---------------
from typing import Any, Callable, Generator, Mapping
from typing import Protocol, Sequence, TYPE_CHECKING
+from typing import Dict, Union # drop with Python 3.8
from . import pq
from ._enums import PyFormat as PyFormat
-from ._compat import TypeAlias, TypeVar
+from ._compat import LiteralString, TypeAlias, TypeVar
if TYPE_CHECKING:
from . import sql # noqa: F401
from .rows import Row, RowMaker
from .pq.abc import PGresult
from .waiting import Wait, Ready # noqa: F401
- from ._compat import LiteralString # noqa: F401
from ._adapters_map import AdaptersMap
from ._connection_base import BaseConnection
NoneType: type = type(None)
# An object implementing the buffer protocol
-Buffer: TypeAlias = "bytes | bytearray | memoryview"
+Buffer: TypeAlias = Union[bytes, bytearray, memoryview]
-Query: TypeAlias = "LiteralString | bytes | sql.SQL | sql.Composed"
-Params: TypeAlias = "Sequence[Any] | Mapping[str, Any]"
+Query: TypeAlias = Union[LiteralString, bytes, "sql.SQL", "sql.Composed"]
+Params: TypeAlias = Union[Sequence[Any], Mapping[str, Any]]
ConnectionType = TypeVar("ConnectionType", bound="BaseConnection[Any]")
PipelineCommand: TypeAlias = Callable[[], None]
-DumperKey: TypeAlias = "type | tuple[DumperKey, ...]"
-ConnParam: TypeAlias = "str | int | None"
-ConnDict: TypeAlias = "dict[str, ConnParam]"
+DumperKey: TypeAlias = Union[type, "tuple[DumperKey, ...]"]
+ConnParam: TypeAlias = Union[str, int, None]
+ConnDict: TypeAlias = Dict[str, ConnParam]
ConnMapping: TypeAlias = Mapping[str, ConnParam]
from __future__ import annotations
from typing import Any, Callable, Protocol, Sequence, TYPE_CHECKING
+from typing import Union # drop with Python 3.8
from ._enums import Format, Trace
from .._compat import Self, TypeAlias
from .misc import PGnotify, ConninfoOption, PGresAttDesc
# An object implementing the buffer protocol (ish)
-Buffer: TypeAlias = "bytes | bytearray | memoryview"
+Buffer: TypeAlias = Union[bytes, bytearray, memoryview]
class PGconn(Protocol):
import functools
from typing import Any, Callable, NamedTuple, NoReturn
from typing import TYPE_CHECKING, Protocol, Sequence
+from typing import Dict, Tuple # drop with Python 3.8
from collections import namedtuple
from . import pq
def __call__(self, __cursor: BaseCursor[Any, Any]) -> RowMaker[Row]: ...
-TupleRow: TypeAlias = "tuple[Any, ...]"
+TupleRow: TypeAlias = Tuple[Any, ...]
"""
An alias for the type returned by `tuple_row()` (i.e. a tuple of any content).
"""
-DictRow: TypeAlias = "dict[str, Any]"
+DictRow: TypeAlias = Dict[str, Any]
"""
An alias for the type returned by `dict_row()`
from __future__ import annotations
from typing import Awaitable, Callable, TYPE_CHECKING
+from typing import Union # drop with Python 3.8
from ._compat import TypeAlias, TypeVar
AsyncConnectionCB: TypeAlias = Callable[[ACT], Awaitable[None]]
# Callbacks to pass the pool to on connection failure
-ConnectFailedCB: TypeAlias = "Callable[[ConnectionPool[Any]], None]"
-AsyncConnectFailedCB: TypeAlias = (
- "Callable[[AsyncConnectionPool[Any]], None]"
- "| Callable[[AsyncConnectionPool[Any]], Awaitable[None]]"
-)
+ConnectFailedCB: TypeAlias = Callable[["ConnectionPool[Any]"], None]
+AsyncConnectFailedCB: TypeAlias = Union[
+ Callable[["AsyncConnectionPool[Any]"], None],
+ Callable[["AsyncConnectionPool[Any]"], Awaitable[None]],
+]