]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Global replace of src -> cls params and attribs
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 31 Dec 2020 03:53:19 +0000 (04:53 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 8 Jan 2021 01:26:53 +0000 (02:26 +0100)
docs/adaptation.rst
psycopg3/psycopg3/types/composite.py
psycopg3/psycopg3/types/date.py
psycopg3/psycopg3/types/text.py
psycopg3_c/psycopg3_c/_psycopg3/adapt.pyx
psycopg3_c/psycopg3_c/types/numeric.pyx
psycopg3_c/psycopg3_c/types/text.pyx

index 54f7be1d9c679706e99c527592401faad19cca04..299e4bcdf041727e96150113ecfa41710f66fedb 100644 (file)
@@ -106,7 +106,7 @@ Objects involved in types adaptation
     :members:
 
 
-.. autoclass:: Dumper(src, context=None)
+.. autoclass:: Dumper(cls, context=None)
 
     This is an abstract base class: subclasses *must* implement the `dump()`
     method and specify the `format`.
@@ -115,8 +115,8 @@ Objects involved in types adaptation
     from the context, but this may fail in some contexts and may require a
     cast.
 
-    :param src: The type that will be managed by this dumper.
-    :type src: type
+    :param cls: The type that will be managed by this dumper.
+    :type cls: type
     :param context: The context where the transformation is performed. If not
         specified the conversion might be inaccurate, for instance it will not
         be possible to know the connection encoding or the server date format.
@@ -157,18 +157,18 @@ Objects involved in types adaptation
 
             Document how to find type OIDs in a database.
 
-    .. automethod:: register(src, context=None)
+    .. automethod:: register(cls, context=None)
 
         You should call this method on the `Dumper` subclass you create,
-        passing the Python type you want to dump as *src*.
+        passing the Python type you want to dump as *cls*.
 
-        :param src: The type to manage.
-        :type src: `!type` or `!str`
+        :param cls: The type to manage.
+        :type cls: `!type` or `!str`
         :param context: Where the dumper should be used. If `!None` the dumper
             will be used globally.
         :type context: `~psycopg3.Connection`, `~psycopg3.Cursor`, or `Transformer`
 
-        If *src* is specified as string it will be lazy-loaded, so that it
+        If *cls* is specified as string it will be lazy-loaded, so that it
         will be possible to register it without importing it before. In this
         case it should be the fully qualified name of the object (e.g.
         ``"uuid.UUID"``).
index 4d727c96d3a49bf27d3363da0cbd41fd3cf3378a..46439dc37d67414dc48d5ac2ddb4ff4ec06a5689 100644 (file)
@@ -147,8 +147,8 @@ class SequenceDumper(Dumper):
 
     format = Format.TEXT
 
-    def __init__(self, src: type, context: Optional[AdaptContext] = None):
-        super().__init__(src, context)
+    def __init__(self, cls: type, context: Optional[AdaptContext] = None):
+        super().__init__(cls, context)
         self._tx = Transformer(context)
 
     def _dump_sequence(
index 2d91bc59eb78aa43285ee2b0a9e1fd2b59449888..2555abd312b02a1a3463190ef35b0a2ca6387627 100644 (file)
@@ -55,8 +55,8 @@ class TimeDeltaDumper(Dumper):
     format = Format.TEXT
     _oid = builtins["interval"].oid
 
-    def __init__(self, src: type, context: Optional[AdaptContext] = None):
-        super().__init__(src, context)
+    def __init__(self, cls: type, context: Optional[AdaptContext] = None):
+        super().__init__(cls, context)
         if self.connection:
             if (
                 self.connection.pgconn.parameter_status(b"IntervalStyle")
index a36eafee73711a978d29121b3ff4126cf14e41d6..a4306cddf36f0831460201689a0494b3b2b1277b 100644 (file)
@@ -20,8 +20,8 @@ class _StringDumper(Dumper):
 
     _encoding = "utf-8"
 
-    def __init__(self, src: type, context: Optional[AdaptContext] = None):
-        super().__init__(src, context)
+    def __init__(self, cls: type, context: Optional[AdaptContext] = None):
+        super().__init__(cls, context)
 
         conn = self.connection
         if conn:
@@ -87,8 +87,8 @@ class BytesDumper(Dumper):
     format = Format.TEXT
     _oid = builtins["bytea"].oid
 
-    def __init__(self, src: type, context: Optional[AdaptContext] = None):
-        super().__init__(src, context)
+    def __init__(self, cls: type, context: Optional[AdaptContext] = None):
+        super().__init__(cls, context)
         self._esc = Escaping(
             self.connection.pgconn if self.connection else None
         )
index aa6d30bfb19cca0b2fba67090dc8e086d01eff68..68c7e5480def5c6554a03f345f324c8b58d4ed92 100644 (file)
@@ -30,13 +30,13 @@ logger = logging.getLogger("psycopg3.adapt")
 
 
 cdef class CDumper:
-    cdef object src
+    cdef object cls
     cdef public libpq.Oid oid
     cdef readonly object connection
     cdef pq.PGconn _pgconn
 
-    def __init__(self, src: type, context: Optional[AdaptContext] = None):
-        self.src = src
+    def __init__(self, cls: type, context: Optional[AdaptContext] = None):
+        self.cls = cls
         self.connection = context.connection if context is not None else None
         self._pgconn = (
             self.connection.pgconn if self.connection is not None else None
@@ -91,7 +91,7 @@ cdef class CDumper:
     @classmethod
     def register(
         cls,
-        src: Union[type, str],
+        cls: Union[type, str],
         context: Optional[AdaptContext] = None,
         int format = Format.TEXT,
     ) -> None:
@@ -100,7 +100,7 @@ cdef class CDumper:
         else:
             from psycopg3.adapt import global_adapters as adapters
 
-        adapters.register_dumper(src, cls)
+        adapters.register_dumper(cls, cls)
 
 
 cdef class CLoader:
index 67a9476533fb934460a0dc34e89b3b441899a606..b33953bdfa487744c77c817b5eee937063ae36ef 100644 (file)
@@ -26,8 +26,8 @@ cdef class IntDumper(CDumper):
     def __cinit__(self):
         self.oid = oids.INT8_OID
 
-    def __init__(self, src: type, context: Optional[AdaptContext] = None):
-        super().__init__(src, context)
+    def __init__(self, cls: type, context: Optional[AdaptContext] = None):
+        super().__init__(cls, context)
 
     def dump(self, obj) -> bytes:
         cdef char buf[22]
index a6a2701d29d7378f309368f70d2098796a7c720f..bebe144bfc64fc05c31178dbb9939ac46fef4a96 100644 (file)
@@ -16,8 +16,8 @@ cdef class _StringDumper(CDumper):
     cdef char *encoding
     cdef bytes _bytes_encoding  # needed to keep `encoding` alive
 
-    def __init__(self, src: type, context: Optional[AdaptContext]):
-        super().__init__(src, context)
+    def __init__(self, cls: type, context: Optional[AdaptContext]):
+        super().__init__(cls, context)
 
         self.is_utf8 = 0
         self.encoding = "utf-8"
@@ -116,8 +116,8 @@ cdef class BytesDumper(CDumper):
     def __cinit__(self):
         self.oid = oids.BYTEA_OID
 
-    def __init__(self, src: type, context: Optional[AdaptContext] = None):
-        super().__init__(src, context)
+    def __init__(self, cls: type, context: Optional[AdaptContext] = None):
+        super().__init__(cls, context)
         self.esc = Escaping(self._pgconn)
 
     def dump(self, obj) -> memoryview: