]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
proto modules renamed to abc
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 12 Jul 2021 15:54:57 +0000 (17:54 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 12 Jul 2021 16:23:11 +0000 (18:23 +0200)
44 files changed:
docs/advanced/adapt.rst
docs/api/abc.rst [moved from docs/api/proto.rst with 95% similarity]
docs/api/adapt.rst
docs/api/index.rst
psycopg/psycopg/_adapters_map.py
psycopg/psycopg/_preparing.py
psycopg/psycopg/_queries.py
psycopg/psycopg/_struct.py
psycopg/psycopg/_transform.py
psycopg/psycopg/_typeinfo.py
psycopg/psycopg/_tz.py
psycopg/psycopg/abc.py [moved from psycopg/psycopg/proto.py with 99% similarity]
psycopg/psycopg/adapt.py
psycopg/psycopg/connection.py
psycopg/psycopg/conninfo.py
psycopg/psycopg/copy.py
psycopg/psycopg/cursor.py
psycopg/psycopg/dbapi20.py
psycopg/psycopg/errors.py
psycopg/psycopg/generators.py
psycopg/psycopg/pool/base.py
psycopg/psycopg/postgres.py
psycopg/psycopg/pq/__init__.py
psycopg/psycopg/pq/abc.py [moved from psycopg/psycopg/pq/proto.py with 100% similarity]
psycopg/psycopg/pq/misc.py
psycopg/psycopg/pq/pq_ctypes.py
psycopg/psycopg/server_cursor.py
psycopg/psycopg/sql.py
psycopg/psycopg/transaction.py
psycopg/psycopg/types/array.py
psycopg/psycopg/types/bool.py
psycopg/psycopg/types/composite.py
psycopg/psycopg/types/datetime.py
psycopg/psycopg/types/json.py
psycopg/psycopg/types/net.py
psycopg/psycopg/types/none.py
psycopg/psycopg/types/numeric.py
psycopg/psycopg/types/range.py
psycopg/psycopg/types/string.py
psycopg/psycopg/types/uuid.py
psycopg/psycopg/waiting.py
psycopg_c/psycopg_c/_psycopg.pyi
psycopg_c/psycopg_c/_psycopg/generators.pyx
tests/adapters_example.py

index 3e5bc468bb81cf517a8f5da672b52f4953b152e1..9e7c57eda16d97cc3260430fae97f9ddb51fd5da 100644 (file)
@@ -17,8 +17,8 @@ returned.
     adaptation rules.
 
 - Adaptation configuration is performed by changing the
-  `~psycopg.proto.AdaptContext.adapters` object of objects implementing the
-  `~psycopg.proto.AdaptContext` protocols, for instance `~psycopg.Connection`
+  `~psycopg.abc.AdaptContext.adapters` object of objects implementing the
+  `~psycopg.abc.AdaptContext` protocols, for instance `~psycopg.Connection`
   or `~psycopg.Cursor`.
 
 - Every context object derived from another context inherits its adapters
@@ -31,21 +31,21 @@ returned.
      :align: center
 
 - The `!adapters` attribute are `AdaptersMap` instances, and contain the
-  mapping from Python types and `~psycopg.proto.Dumper` classes, and from
-  PostgreSQL oids to `~psycopg.proto.Loader` classes. Changing this mapping
+  mapping from Python types and `~psycopg.abc.Dumper` classes, and from
+  PostgreSQL oids to `~psycopg.abc.Loader` classes. Changing this mapping
   (e.g. writing and registering your own adapters, or using a different
   configuration of builtin adapters) affects how types are converted between
   Python and PostgreSQL.
 
-  - Dumpers (objects implementing the `~psycopg.proto.Dumper` protocol) are
+  - Dumpers (objects implementing the `~psycopg.abc.Dumper` protocol) are
     the objects used to perform the conversion from a Python object to a bytes
     sequence in a format understood by PostgreSQL. The string returned
     *shouldn't be quoted*: the value will be passed to the database using
     functions such as :pq:`PQexecParams()` so quoting and quotes escaping is
     not necessary. The dumper usually also suggests the server what type to
-    use, via its `~psycopg.proto.Dumper.oid` attribute.
+    use, via its `~psycopg.abc.Dumper.oid` attribute.
 
-  - Loaders (objects implementing the `~psycopg.proto.Loader` protocol) are
+  - Loaders (objects implementing the `~psycopg.abc.Loader` protocol) are
     the objects used to perform the opposite operation: reading a bytes
     sequence from PostgreSQL and create a Python object out of it.
 
@@ -141,7 +141,7 @@ and dispatching the values to convert to the right instance.
   type to use (for instance the PostgreSQL type of a Python list depends on
   the objects it contains, whether to use an :sql:`integer` or :sql:`bigint`
   depends on the number size...) In these cases the mechanism provided by
-  `~psycopg.proto.Dumper.get_key()` and `~psycopg.proto.Dumper.upgrade()` is
+  `~psycopg.abc.Dumper.get_key()` and `~psycopg.abc.Dumper.upgrade()` is
   used.
 
 - For every OID returned by the query, the `!Transformer` will instantiate a
similarity index 95%
rename from docs/api/proto.rst
rename to docs/api/abc.rst
index 85e0605f24a9e8cb8c082124e2af894f13f97b87..ad20f26e8ee500fda845b90c2021dec838b546d7 100644 (file)
@@ -1,12 +1,10 @@
-`proto` -- Psycopg abstract classes
-===================================
-
-TODO: rename to abc
+`!abc` -- Psycopg abstract classes
+==================================
 
 The module exposes Psycopg definitions which can be used for static type
 checking.
 
-.. module:: psycopg.proto
+.. module:: psycopg.abc
 
 .. autoclass:: Dumper(cls, context=None)
 
index 02553f39274f86dae0da920266a91cf69f591736..c36ea540a614defad0d057bbedf85844b7ece52e 100644 (file)
@@ -23,7 +23,7 @@ Dumpers and loaders
     This is an abstract base class: subclasses *must* at least implement the
     `dump()` method and specify the `format`.
 
-    The class implements the `~psycopg.proto.Dumper` protocol.
+    The class implements the `~psycopg.abc.Dumper` protocol.
 
     .. automethod:: dump
 
@@ -39,7 +39,7 @@ Dumpers and loaders
     This is an abstract base class: subclasses *must* at least implement the
     `!load()` method and specify a `format`.
 
-    The class implements the `~psycopg.proto.Loader` protocol.
+    The class implements the `~psycopg.abc.Loader` protocol.
 
     .. automethod:: load
 
@@ -79,4 +79,4 @@ Other objects used in adaptations
 .. autoclass:: Transformer(context=None)
 
     :param context: The context where the transformer should operate.
-    :type context: `~psycopg.proto.AdaptContext`
+    :type context: `~psycopg.abc.AdaptContext`
index 2064ebb4aa5fb6a581055b9e7ad146d69d4e9fc3..44263f27289f78b12ce010460eaef0fb106357ca 100644 (file)
@@ -11,6 +11,6 @@ Psycopg 3 API
     errors
     adapt
     types
-    proto
+    abc
     pool
     pq
index 3bef245f1e0caf8ac1b40e5852df66897a1338ab..b572e7818f2d23d755e3fced094d0802e2ca2a58 100644 (file)
@@ -9,8 +9,8 @@ from typing import cast, TYPE_CHECKING
 
 from . import pq
 from . import errors as e
+from .abc import Dumper, Loader
 from ._enums import PyFormat as PyFormat
-from .proto import Dumper, Loader
 from ._cmodule import _psycopg
 from ._typeinfo import TypesRegistry
 
@@ -23,7 +23,7 @@ RV = TypeVar("RV")
 class AdaptersMap:
     r"""
     Establish how types should be converted between Python and PostgreSQL in
-    an `~psycopg.proto.AdaptContext`.
+    an `~psycopg.abc.AdaptContext`.
 
     `!AdaptersMap` maps Python types to `~psycopg.adapt.Dumper` classes to
     define how Python types are converted to PostgreSQL, and maps OIDs to
@@ -32,7 +32,7 @@ class AdaptersMap:
 
     Every `!AdaptContext` object has an underlying `!AdaptersMap` defining how
     types are converted in that context, exposed as the
-    `~psycopg.proto.AdaptContext.adapters` attribute: changing such map allows
+    `~psycopg.abc.AdaptContext.adapters` attribute: changing such map allows
     to customise adaptation in a context without changing separated contexts.
 
     When a context is created from another context (for instance when a
index c983965f7d1735199b93d7ac4d1942989373eab7..13c07901ac39428fca2083d2adff438d298c36e8 100644 (file)
@@ -12,7 +12,7 @@ from .pq import ExecStatus
 from ._queries import PostgresQuery
 
 if TYPE_CHECKING:
-    from .pq.proto import PGresult
+    from .pq.abc import PGresult
 
 
 class Prepare(IntEnum):
index 4732c1fee772271e4cd2e6098da74214a9dcaee2..4a492bd3a65e4581faca7ee3372e49dd3ccd6761 100644 (file)
@@ -12,11 +12,11 @@ from functools import lru_cache
 from . import pq
 from . import errors as e
 from .sql import Composable
-from .proto import Query, Params
+from .abc import Query, Params
 from ._enums import PyFormat
 
 if TYPE_CHECKING:
-    from .proto import Transformer
+    from .abc import Transformer
 
 
 class QueryPart(NamedTuple):
index 3bb798abb1aa5823853db914cdaecc3161507997..e4529ff0854f1dcd42c4156c17c079aa09ab46ba 100644 (file)
@@ -7,7 +7,7 @@ Utility functions to deal with binary structs.
 import struct
 from typing import Callable, cast, Optional, Tuple
 
-from .proto import Buffer
+from .abc import Buffer
 from .compat import Protocol
 
 PackInt = Callable[[int], bytes]
index 11a549ca18abbaed3f5470c9026858d7d57cdfb0..4f7dae357a3ff124fa8d4e7b4af0e53935587c64 100644 (file)
@@ -11,14 +11,14 @@ from collections import defaultdict
 from . import pq
 from . import postgres
 from . import errors as e
+from .abc import LoadFunc, AdaptContext, PyFormat, DumperKey
 from .rows import Row, RowMaker
-from .proto import LoadFunc, AdaptContext, PyFormat, DumperKey
 from .postgres import INVALID_OID
 
 if TYPE_CHECKING:
-    from .pq.proto import PGresult
+    from .abc import Dumper, Loader
     from .adapt import AdaptersMap
-    from .proto import Dumper, Loader
+    from .pq.abc import PGresult
     from .connection import BaseConnection
 
 DumperCache = Dict[DumperKey, "Dumper"]
index e8a15dd3e17e43fa8ba82996205d2731b2a96c43..1d9f5c89a18e5173e9102932018a46015e87b798 100644 (file)
@@ -11,8 +11,8 @@ from typing import Any, Callable, Dict, Iterator, Optional
 from typing import Sequence, Type, TypeVar, Union, TYPE_CHECKING
 
 from . import errors as e
+from .abc import AdaptContext
 from .rows import dict_row
-from .proto import AdaptContext
 
 if TYPE_CHECKING:
     from .connection import Connection, AsyncConnection
index 5b34203ad4bd3ea79547e6d919f4a09540e3ad89..ac5af7d139c10ccd3da395f2dfb41a65890afb02 100644 (file)
@@ -9,7 +9,7 @@ from typing import Dict, Optional, Union
 from datetime import timezone, tzinfo
 
 from .compat import ZoneInfo
-from .pq.proto import PGconn
+from .pq.abc import PGconn
 
 logger = logging.getLogger("psycopg")
 
similarity index 99%
rename from psycopg/psycopg/proto.py
rename to psycopg/psycopg/abc.py
index 1fa915a4e6dabbea81ba2ba22bc393613fb2114e..a0158e2d3101165baa68bdbb55b51bbe3314ea5f 100644 (file)
@@ -15,7 +15,7 @@ from .compat import Protocol
 if TYPE_CHECKING:
     from .sql import Composable
     from .rows import Row, RowMaker
-    from .pq.proto import PGresult
+    from .pq.abc import PGresult
     from .waiting import Wait, Ready
     from .connection import BaseConnection
     from ._adapters_map import AdaptersMap
index 78196a6380770be407104a5dd63be12c6cb481a7..06d38d51cfa2787276df02468c30ddc82ac0e02e 100644 (file)
@@ -7,9 +7,8 @@ Entry point into the adaptation system.
 from abc import ABC, abstractmethod
 from typing import Any, Optional, Type, Tuple, Union, TYPE_CHECKING
 
-from . import pq, proto
+from . import pq, abc
 from . import _adapters_map
-from .proto import AdaptContext, Buffer as Buffer
 from ._enums import PyFormat as PyFormat
 from ._cmodule import _psycopg
 
@@ -17,9 +16,10 @@ if TYPE_CHECKING:
     from .connection import BaseConnection
 
 AdaptersMap = _adapters_map.AdaptersMap
+Buffer = abc.Buffer
 
 
-class Dumper(proto.Dumper, ABC):
+class Dumper(abc.Dumper, ABC):
     """
     Convert Python object of the type *cls* to PostgreSQL representation.
     """
@@ -31,7 +31,7 @@ class Dumper(proto.Dumper, ABC):
     oid: int
     """The oid to pass to the server, if known."""
 
-    def __init__(self, cls: type, context: Optional[AdaptContext] = None):
+    def __init__(self, cls: type, context: Optional[abc.AdaptContext] = None):
         self.cls = cls
         self.connection: Optional["BaseConnection[Any]"] = (
             context.connection if context else None
@@ -63,8 +63,8 @@ class Dumper(proto.Dumper, ABC):
         self, obj: Any, format: PyFormat
     ) -> Union[type, Tuple[type, ...]]:
         """
-        Implementation of the `~psycopg.proto.Dumper.get_key()` member of the
-        `~psycopg.proto.Dumper` protocol. Look at its definition for details.
+        Implementation of the `~psycopg.abc.Dumper.get_key()` member of the
+        `~psycopg.abc.Dumper` protocol. Look at its definition for details.
 
         This implementation returns the *cls* passed in the constructor.
         Subclasses needing to specialise the PostgreSQL type according to the
@@ -76,8 +76,8 @@ class Dumper(proto.Dumper, ABC):
 
     def upgrade(self, obj: Any, format: PyFormat) -> "Dumper":
         """
-        Implementation of the `~psycopg.proto.Dumper.upgrade()` member of the
-        `~psycopg.proto.Dumper` protocol. Look at its definition for details.
+        Implementation of the `~psycopg.abc.Dumper.upgrade()` member of the
+        `~psycopg.abc.Dumper` protocol. Look at its definition for details.
 
         This implementation just returns *self*. If a subclass implements
         `get_key()` it should probably override `!upgrade()` too.
@@ -92,7 +92,7 @@ class Loader(ABC):
 
     format: pq.Format
 
-    def __init__(self, oid: int, context: Optional[AdaptContext] = None):
+    def __init__(self, oid: int, context: Optional[abc.AdaptContext] = None):
         self.oid = oid
         self.connection: Optional["BaseConnection[Any]"] = (
             context.connection if context else None
@@ -104,7 +104,7 @@ class Loader(ABC):
         ...
 
 
-Transformer: Type["proto.Transformer"]
+Transformer: Type["abc.Transformer"]
 
 # Override it with fast object if available
 if _psycopg:
@@ -118,7 +118,7 @@ else:
 class RecursiveDumper(Dumper):
     """Dumper with a transformer to help dumping recursive types."""
 
-    def __init__(self, cls: type, context: Optional[AdaptContext] = None):
+    def __init__(self, cls: type, context: Optional[abc.AdaptContext] = None):
         super().__init__(cls, context)
         self._tx = Transformer(context)
 
@@ -126,6 +126,6 @@ class RecursiveDumper(Dumper):
 class RecursiveLoader(Loader):
     """Loader with a transformer to help loading recursive types."""
 
-    def __init__(self, oid: int, context: Optional[AdaptContext] = None):
+    def __init__(self, oid: int, context: Optional[abc.AdaptContext] = None):
         super().__init__(oid, context)
         self._tx = Transformer(context)
index c00479641c639e5e9c4268e3b03adbb35c3c0f6e..64a158d49c2ef821425dd0e0aca6747296d8f0db 100644 (file)
@@ -23,10 +23,9 @@ from . import waiting
 from . import postgres
 from . import encodings
 from .pq import ConnStatus, ExecStatus, TransactionStatus, Format
+from .abc import ConnectionType, Params, PQGen, PQGenConn, Query, RV
 from .sql import Composable
 from .rows import Row, RowFactory, tuple_row, TupleRow
-from .proto import ConnectionType, Params, PQGen, PQGenConn
-from .proto import Query, RV
 from .compat import asynccontextmanager
 from .cursor import Cursor, AsyncCursor
 from ._cmodule import _psycopg
@@ -46,7 +45,7 @@ execute: Callable[["PGconn"], PQGen[List["PGresult"]]]
 CursorRow = TypeVar("CursorRow")
 
 if TYPE_CHECKING:
-    from .pq.proto import PGconn, PGresult
+    from .pq.abc import PGconn, PGresult
     from .pool.base import BasePool
 
 if _psycopg:
index 469117dde25de2f4d1819646a57fdbf6b28493c9..3d665c94b7c2e724c07e0a26239d364454849b35 100644 (file)
@@ -116,7 +116,7 @@ class ConnectionInfo:
 
     __module__ = "psycopg"
 
-    def __init__(self, pgconn: pq.proto.PGconn):
+    def __init__(self, pgconn: pq.abc.PGconn):
         self.pgconn = pgconn
 
     @property
index 5829189bdfb228e1178b0a2028fb71b4fa1d235a..c933e7e89710ec89de8c2d7d8d687581055f0868 100644 (file)
@@ -17,14 +17,14 @@ from typing import Any, Dict, List, Match, Optional, Sequence, Type, Tuple
 from . import pq
 from . import errors as e
 from .pq import ExecStatus
+from .abc import ConnectionType, PQGen, Transformer
 from .adapt import PyFormat
-from .proto import ConnectionType, PQGen, Transformer
 from .compat import create_task
 from ._cmodule import _psycopg
 from .generators import copy_from, copy_to, copy_end
 
 if TYPE_CHECKING:
-    from .pq.proto import PGresult
+    from .pq.abc import PGresult
     from .cursor import BaseCursor, Cursor, AsyncCursor
     from .connection import Connection, AsyncConnection  # noqa: F401
 
index 3fa4ac93c589cd21f283adb7b2e123beedfa9a5b..4e1946524122943be375cfc1ddae90f7d6ac907d 100644 (file)
@@ -16,9 +16,9 @@ from . import errors as e
 from . import generators
 
 from .pq import ExecStatus, Format
+from .abc import ConnectionType, Query, Params, PQGen
 from .copy import Copy, AsyncCopy
 from .rows import Row, RowFactory
-from .proto import ConnectionType, Query, Params, PQGen
 from .compat import asynccontextmanager
 from ._column import Column
 from ._cmodule import _psycopg
@@ -26,8 +26,8 @@ from ._queries import PostgresQuery
 from ._preparing import Prepare
 
 if TYPE_CHECKING:
-    from .proto import Transformer
-    from .pq.proto import PGconn, PGresult
+    from .abc import Transformer
+    from .pq.abc import PGconn, PGresult
     from .connection import BaseConnection  # noqa: F401
     from .connection import Connection, AsyncConnection  # noqa: F401
 
index a6a75db226ca1cd5e6071fd424eeef78cb3c8bd1..78f8f66fc923bf6ba22a3b7f5c80d224cf307bbf 100644 (file)
@@ -11,8 +11,8 @@ from typing import Any, Optional, Sequence
 
 from . import postgres
 from .pq import Format, Escaping
+from .abc import AdaptContext
 from .adapt import Dumper
-from .proto import AdaptContext
 
 
 class DBAPITypeObject:
index 80e36c5b66ef4a1bdfe65335ce0f03d9a09222cd..9daa4a379fda659d2c2e69b64ba4f56ab4761b2a 100644 (file)
@@ -20,7 +20,8 @@ DBAPI-defined Exceptions are defined in the following hierarchy::
 
 from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Type, Union
 from typing import cast
-from psycopg.pq.proto import PGresult
+
+from psycopg.pq.abc import PGresult
 from psycopg.pq._enums import DiagnosticField
 
 
index 95b2994d45619fac6e974691d6053a0365440325..86c13c2887471e07047aa149772e66cce5ce4184 100644 (file)
@@ -21,10 +21,10 @@ from typing import List, Optional, Union
 from . import pq
 from . import errors as e
 from .pq import ConnStatus, PollingStatus, ExecStatus
-from .proto import PQGen, PQGenConn
+from .abc import PQGen, PQGenConn
 from .waiting import Wait, Ready
 from .encodings import py_codecs
-from .pq.proto import PGconn, PGresult
+from .pq.abc import PGconn, PGresult
 
 logger = logging.getLogger(__name__)
 
index f652ecfe528f54c336ae40c4f6bb262c626fafee..55c25301c30dc4cb6fe91b23b208963acbbdd85e 100644 (file)
@@ -9,7 +9,7 @@ from typing import Any, Callable, Deque, Dict, Generic, Optional
 from typing import TYPE_CHECKING
 from collections import Counter, deque
 
-from ..proto import ConnectionType
+from ..abc import ConnectionType
 
 if TYPE_CHECKING:
     from typing import Counter as TCounter
index c48e1399622df7ce4a91ae3475dd4b0e8f2da19a..396e409d44c9b25e6f57386b46e8d6ddd442f3f0 100644 (file)
@@ -5,7 +5,7 @@ Types configuration specific to PostgreSQL.
 # Copyright (C) 2020-2021 The Psycopg Team
 
 from ._typeinfo import TypeInfo, RangeInfo, TypesRegistry
-from .proto import AdaptContext
+from .abc import AdaptContext
 from ._adapters_map import AdaptersMap
 
 # Global objects with PostgreSQL builtins and globally registered user types.
index 50773d92e42fe6c49995ef52ffad98425e9f183c..e78f6b6eca345e593c7a867ef132b05288daa2c1 100644 (file)
@@ -13,11 +13,11 @@ import os
 import logging
 from typing import Callable, List, Type
 
+from . import abc
 from .misc import ConninfoOption, PGnotify, PGresAttDesc
 from .misc import error_message
 from ._enums import ConnStatus, DiagnosticField, ExecStatus, Format
 from ._enums import Ping, PollingStatus, TransactionStatus
-from . import proto
 
 logger = logging.getLogger(__name__)
 
@@ -28,11 +28,11 @@ Possible values include ``python``, ``c``, ``binary``.
 """
 
 version: Callable[[], int]
-PGconn: Type[proto.PGconn]
-PGresult: Type[proto.PGresult]
-Conninfo: Type[proto.Conninfo]
-Escaping: Type[proto.Escaping]
-PGcancel: Type[proto.PGcancel]
+PGconn: Type[abc.PGconn]
+PGresult: Type[abc.PGresult]
+Conninfo: Type[abc.Conninfo]
+Escaping: Type[abc.Escaping]
+PGcancel: Type[abc.PGcancel]
 
 
 def import_from_libpq() -> None:
index ae145fdb299b8f9458d7c3b9841c7b93e6c16785..b5f2c63de7b7359faa3723662812ae41398e0cad 100644 (file)
@@ -6,8 +6,8 @@ Various functionalities to make easier to work with the libpq.
 
 from typing import cast, NamedTuple, Optional, Union
 
+from .abc import PGconn, PGresult
 from ._enums import ConnStatus, TransactionStatus
-from .proto import PGconn, PGresult
 
 
 class PGnotify(NamedTuple):
index 6f4341b6396dc6775db9eca6bf6baefc6164caa6..bf632d6fd3137c26768c2d7fcac2f91dba80ba86 100644 (file)
@@ -25,7 +25,7 @@ from .misc import error_message, connection_summary
 from ._enums import Format, ExecStatus
 
 if TYPE_CHECKING:
-    from . import proto
+    from . import abc
 
 __impl__ = "python"
 
@@ -70,9 +70,7 @@ class PGconn:
 
     def __init__(self, pgconn_ptr: impl.PGconn_struct):
         self._pgconn_ptr: Optional[impl.PGconn_struct] = pgconn_ptr
-        self.notice_handler: Optional[
-            Callable[["proto.PGresult"], None]
-        ] = None
+        self.notice_handler: Optional[Callable[["abc.PGresult"], None]] = None
         self.notify_handler: Optional[Callable[[PGnotify], None]] = None
 
         self._notice_receiver = impl.PQnoticeReceiver(  # type: ignore
@@ -881,7 +879,7 @@ class Escaping:
     def __init__(self, conn: Optional[PGconn] = None):
         self.conn = conn
 
-    def escape_literal(self, data: "proto.Buffer") -> memoryview:
+    def escape_literal(self, data: "abc.Buffer") -> memoryview:
         if not self.conn:
             raise e.OperationalError(
                 "escape_literal failed: no connection provided"
@@ -900,7 +898,7 @@ class Escaping:
         impl.PQfreemem(out)
         return memoryview(rv)
 
-    def escape_identifier(self, data: "proto.Buffer") -> memoryview:
+    def escape_identifier(self, data: "abc.Buffer") -> memoryview:
         if not self.conn:
             raise e.OperationalError(
                 "escape_identifier failed: no connection provided"
@@ -919,7 +917,7 @@ class Escaping:
         impl.PQfreemem(out)
         return memoryview(rv)
 
-    def escape_string(self, data: "proto.Buffer") -> memoryview:
+    def escape_string(self, data: "abc.Buffer") -> memoryview:
         if not isinstance(data, bytes):
             data = bytes(data)
 
@@ -950,7 +948,7 @@ class Escaping:
 
         return memoryview(out.value)
 
-    def escape_bytea(self, data: "proto.Buffer") -> memoryview:
+    def escape_bytea(self, data: "abc.Buffer") -> memoryview:
         len_out = c_size_t()
         # TODO: might be able to do without a copy but it's a mess.
         # the C library does it better anyway, so maybe not worth optimising
index 39e2e01553cc0dd743507bd07a3b43a43aeb2efe..2367c68035bd79539d06f62aa0d919c1e1d5bcf8 100644 (file)
@@ -12,8 +12,8 @@ from typing import Sequence, Type, TYPE_CHECKING
 from . import pq
 from . import sql
 from . import errors as e
+from .abc import ConnectionType, Query, Params, PQGen
 from .rows import Row, RowFactory
-from .proto import ConnectionType, Query, Params, PQGen
 from .cursor import BaseCursor, execute
 
 if TYPE_CHECKING:
index 740c35dcb38d8899495ed022652891ebc79ec66e..abc5bc4bb177ce593ae7978f107f7a0c0117e223 100644 (file)
@@ -10,8 +10,8 @@ from abc import ABC, abstractmethod
 from typing import Any, Iterator, List, Optional, Sequence, Union
 
 from .pq import Escaping
+from .abc import AdaptContext
 from .adapt import Transformer, PyFormat
-from .proto import AdaptContext
 
 
 def quote(obj: Any, context: Optional[AdaptContext] = None) -> str:
index e3e54d2a04f144d9d183b6507b16547a48a8e403..2804e1e6fcfd931dcb2b830e1de2d04106949e93 100644 (file)
@@ -12,8 +12,8 @@ from typing import Generic, Optional, Type, Union, TYPE_CHECKING
 from . import pq
 from . import sql
 from .pq import TransactionStatus
-from .proto import ConnectionType, PQGen
-from .pq.proto import PGresult
+from .abc import ConnectionType, PQGen
+from .pq.abc import PGresult
 
 if TYPE_CHECKING:
     from typing import Any  # noqa: F401
index 1cc09148f023451586877e36cb4a7f6caf264ae1..740c803c9bcdf6a530c7f250be5044a848e57ac6 100644 (file)
@@ -12,8 +12,8 @@ from typing import cast
 from .. import pq
 from .. import errors as e
 from .. import postgres
+from ..abc import AdaptContext, Buffer, Dumper, DumperKey
 from ..adapt import RecursiveDumper, RecursiveLoader, PyFormat
-from ..proto import AdaptContext, Buffer, Dumper, DumperKey
 from .._struct import pack_len, unpack_len
 from ..postgres import TEXT_OID, INVALID_OID
 from .._typeinfo import TypeInfo
index c9b9de8a798c3a556c65529721470529443e39f2..47b77fb179a0bb12ccbd901b1798cf7bceeb1448 100644 (file)
@@ -6,8 +6,8 @@ Adapters for booleans.
 
 from .. import postgres
 from ..pq import Format
+from ..abc import AdaptContext
 from ..adapt import Buffer, Dumper, Loader
-from ..proto import AdaptContext
 
 
 class BoolDumper(Dumper):
index 5ea8613a91e9f2254a67771e55a5f0fc99daa94c..5cc567efee1102f2dfaca49078d03e5a0221332d 100644 (file)
@@ -12,8 +12,8 @@ from typing import Sequence, Tuple, Type
 
 from .. import pq
 from .. import postgres
+from ..abc import AdaptContext, Buffer
 from ..adapt import PyFormat, RecursiveDumper, RecursiveLoader
-from ..proto import AdaptContext, Buffer
 from .._struct import unpack_len
 from ..postgres import TEXT_OID
 from .._typeinfo import CompositeInfo as CompositeInfo  # exported here
index e9317f6ef8c52eb896fc102f35fe65c1c792ca1a..e73af2c4309d660f8c47425468d1015095737b7c 100644 (file)
@@ -13,8 +13,8 @@ from typing import Any, Callable, cast, Optional, Tuple, TYPE_CHECKING
 from .. import postgres
 from ..pq import Format
 from .._tz import get_tzinfo
+from ..abc import AdaptContext, DumperKey
 from ..adapt import Buffer, Dumper, Loader, PyFormat
-from ..proto import AdaptContext, DumperKey
 from ..errors import InterfaceError, DataError
 from .._struct import pack_int4, pack_int8, unpack_int4, unpack_int8
 
index 88e6922655ba56819dfaa380ec89f9c9dc003d44..efb9b876322e6d6e777df639b0e35438505b7111 100644 (file)
@@ -9,8 +9,8 @@ from typing import Any, Callable, Optional, Type, Union
 
 from .. import postgres
 from ..pq import Format
+from ..abc import AdaptContext
 from ..adapt import Buffer, Dumper, Loader
-from ..proto import AdaptContext
 from ..errors import DataError
 
 JsonDumpsFunction = Callable[[Any], str]
index e3e844ea3d90a416ca01637f8d2755a9fc880cc3..96cf1c76a2d899ef369a1bc35bc3d7968819520d 100644 (file)
@@ -8,8 +8,8 @@ from typing import Callable, Optional, Type, Union, TYPE_CHECKING
 
 from .. import postgres
 from ..pq import Format
+from ..abc import AdaptContext
 from ..adapt import Buffer, Dumper, Loader
-from ..proto import AdaptContext
 
 if TYPE_CHECKING:
     import ipaddress
index 6f9fdc2b0d0fc9f5f84539373d4656b40a56ca3d..958a20c3451cd7470d312c5bc00d71824a9cdc1c 100644 (file)
@@ -5,8 +5,8 @@ Adapters for None.
 # Copyright (C) 2020-2021 The Psycopg Team
 
 from ..pq import Format
+from ..abc import AdaptContext
 from ..adapt import Dumper
-from ..proto import AdaptContext
 
 
 class NoneDumper(Dumper):
index 72e218f3192dae75ef8cbb9683061ac57f3940e8..93fa217bbec6b2af31f727af3c65f070eaa9b2cc 100644 (file)
@@ -12,8 +12,8 @@ from decimal import Decimal, DefaultContext, Context
 from .. import postgres
 from .. import errors as e
 from ..pq import Format
+from ..abc import AdaptContext
 from ..adapt import Buffer, Dumper, Loader, PyFormat
-from ..proto import AdaptContext
 from .._struct import pack_int2, pack_uint2, unpack_int2
 from .._struct import pack_int4, pack_uint4, unpack_int4, unpack_uint4
 from .._struct import pack_int8, unpack_int8
index 2be4806ba1681e69e934330d3b9514abb6c8c2e1..41e89806fe427deffa0b2ea17130650c1b7fbfd8 100644 (file)
@@ -12,8 +12,8 @@ from datetime import date, datetime
 
 from .. import postgres
 from ..pq import Format
+from ..abc import AdaptContext, Buffer, Dumper, DumperKey
 from ..adapt import RecursiveDumper, RecursiveLoader, PyFormat
-from ..proto import AdaptContext, Buffer, Dumper, DumperKey
 from .._struct import pack_len, unpack_len
 from ..postgres import INVALID_OID
 from .._typeinfo import RangeInfo as RangeInfo  # exported here
index 8c1f6a16c0682319bf8ab9f19063ad4b99544fa6..de02b42ab3f8b972399b68b8ac71fb50b7d36bc6 100644 (file)
@@ -8,12 +8,12 @@ from typing import Optional, Union, TYPE_CHECKING
 
 from .. import postgres
 from ..pq import Format, Escaping
+from ..abc import AdaptContext
 from ..adapt import Buffer, Dumper, Loader
-from ..proto import AdaptContext
 from ..errors import DataError
 
 if TYPE_CHECKING:
-    from ..pq.proto import Escaping as EscapingProto
+    from ..pq.abc import Escaping as EscapingProto
 
 
 class _StrDumper(Dumper):
index 917e25366f19cbdd1231f055b34b2c61e865d7c0..133666c5c8819c078405d4bd733a62ca3dbabf43 100644 (file)
@@ -8,8 +8,8 @@ from typing import Callable, Optional, TYPE_CHECKING
 
 from .. import postgres
 from ..pq import Format
+from ..abc import AdaptContext
 from ..adapt import Buffer, Dumper, Loader
-from ..proto import AdaptContext
 
 if TYPE_CHECKING:
     import uuid
index f4a779cfe22484d95322ce49cbb31ccc0df1211c..2c2f75bc934ee41abb657c0ed2fc725d627b1e2a 100644 (file)
@@ -17,7 +17,7 @@ from asyncio import get_event_loop, wait_for, Event, TimeoutError
 from selectors import DefaultSelector, EVENT_READ, EVENT_WRITE
 
 from . import errors as e
-from .proto import PQGen, PQGenConn, RV
+from .abc import PQGen, PQGenConn, RV
 
 
 class Wait(IntEnum):
index f0e9846d061afd0ec871a9dbd0c7710589ce4285..e4f6b3e14763fb3f365b447b1bc27d7f02d4750b 100644 (file)
@@ -10,15 +10,14 @@ information. Will submit a bug.
 from typing import Any, Iterable, List, Optional, Sequence, Tuple
 
 from psycopg import pq
-from psycopg import proto
+from psycopg import abc
 from psycopg.rows import Row, RowMaker
 from psycopg.adapt import AdaptersMap, PyFormat
-from psycopg.proto import Dumper, Loader
-from psycopg.pq.proto import PGconn, PGresult
+from psycopg.pq.abc import PGconn, PGresult
 from psycopg.connection import BaseConnection
 
-class Transformer(proto.AdaptContext):
-    def __init__(self, context: Optional[proto.AdaptContext] = None): ...
+class Transformer(abc.AdaptContext):
+    def __init__(self, context: Optional[abc.AdaptContext] = None): ...
     @property
     def connection(self) -> Optional[BaseConnection[Any]]: ...
     @property
@@ -34,7 +33,7 @@ class Transformer(proto.AdaptContext):
     def dump_sequence(
         self, params: Sequence[Any], formats: Sequence[PyFormat]
     ) -> Tuple[List[Any], Tuple[int, ...], Sequence[pq.Format]]: ...
-    def get_dumper(self, obj: Any, format: PyFormat) -> Dumper: ...
+    def get_dumper(self, obj: Any, format: PyFormat) -> abc.Dumper: ...
     def load_rows(
         self, row0: int, row1: int, make_row: RowMaker[Row]
     ) -> List[Row]: ...
@@ -42,22 +41,20 @@ class Transformer(proto.AdaptContext):
     def load_sequence(
         self, record: Sequence[Optional[bytes]]
     ) -> Tuple[Any, ...]: ...
-    def get_loader(self, oid: int, format: pq.Format) -> Loader: ...
+    def get_loader(self, oid: int, format: pq.Format) -> abc.Loader: ...
 
 # Generators
-def connect(conninfo: str) -> proto.PQGenConn[PGconn]: ...
-def execute(pgconn: PGconn) -> proto.PQGen[List[PGresult]]: ...
+def connect(conninfo: str) -> abc.PQGenConn[PGconn]: ...
+def execute(pgconn: PGconn) -> abc.PQGen[List[PGresult]]: ...
 
 # Copy support
 def format_row_text(
-    row: Sequence[Any], tx: proto.Transformer, out: Optional[bytearray] = None
+    row: Sequence[Any], tx: abc.Transformer, out: Optional[bytearray] = None
 ) -> bytearray: ...
 def format_row_binary(
-    row: Sequence[Any], tx: proto.Transformer, out: Optional[bytearray] = None
+    row: Sequence[Any], tx: abc.Transformer, out: Optional[bytearray] = None
 ) -> bytearray: ...
-def parse_row_text(data: bytes, tx: proto.Transformer) -> Tuple[Any, ...]: ...
-def parse_row_binary(
-    data: bytes, tx: proto.Transformer
-) -> Tuple[Any, ...]: ...
+def parse_row_text(data: bytes, tx: abc.Transformer) -> Tuple[Any, ...]: ...
+def parse_row_binary(data: bytes, tx: abc.Transformer) -> Tuple[Any, ...]: ...
 
 # vim: set syntax=python:
index 2a1e5f319b60ed6a859d156fbe53c19d522d070c..78a91fbc2167d5ddf6f725385377533310474e1a 100644 (file)
@@ -10,8 +10,8 @@ import logging
 from typing import List
 
 from psycopg import errors as e
-from psycopg.pq import proto, error_message
-from psycopg.proto import PQGen
+from psycopg.pq import abc, error_message
+from psycopg.abc import PQGen
 from psycopg.waiting import Wait, Ready
 
 cdef object WAIT_W = Wait.W
@@ -19,7 +19,7 @@ cdef object WAIT_R = Wait.R
 cdef object WAIT_RW = Wait.RW
 cdef int READY_R = Ready.R
 
-def connect(conninfo: str) -> PQGenConn[proto.PGconn]:
+def connect(conninfo: str) -> PQGenConn[abc.PGconn]:
     """
     Generator to create a database connection without blocking.
 
@@ -55,7 +55,7 @@ def connect(conninfo: str) -> PQGenConn[proto.PGconn]:
     return conn
 
 
-def execute(pq.PGconn pgconn) -> PQGen[List[proto.PGresult]]:
+def execute(pq.PGconn pgconn) -> PQGen[List[abc.PGresult]]:
     """
     Generator sending a query and returning results without blocking.
 
index 57ff380914f947c1fa39dbb922f4b508fd62b356..6460e76f99a5da274cda7404167f10afd214e099 100644 (file)
@@ -1,7 +1,7 @@
 from typing import Optional, Tuple, Union
 
 from psycopg import pq
-from psycopg.proto import Dumper, Loader, AdaptContext, PyFormat, Buffer
+from psycopg.abc import Dumper, Loader, AdaptContext, PyFormat, Buffer
 
 
 def f() -> None: