From: Daniele Varrazzo Date: Sun, 11 Jul 2021 02:16:25 +0000 (+0200) Subject: Drop .register() method from Dumper/Loader classes X-Git-Tag: 3.0.dev1~28^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=591850afa9be1a7a318b6f145faa81dcbdedc683;p=thirdparty%2Fpsycopg.git Drop .register() method from Dumper/Loader classes Use the register_dumper/loader() method on the adapters, readily available from the context. A bit of a violation of Demeter law, but much more intuitive and simplifies the Dumper/Loader interface (the methods were outside the protocol). --- diff --git a/psycopg/psycopg/adapt.py b/psycopg/psycopg/adapt.py index d2d61daab..08578c865 100644 --- a/psycopg/psycopg/adapt.py +++ b/psycopg/psycopg/adapt.py @@ -87,18 +87,6 @@ class Dumper(ABC): """ return self - @classmethod - def register( - this_cls, cls: Union[type, str], context: Optional[AdaptContext] = None - ) -> None: - """ - Configure *context* to use this dumper to convert object of type *cls*. - """ - from . import postgres - - adapters = context.adapters if context else postgres.adapters - adapters.register_dumper(cls, this_cls) - class Loader(ABC): """ @@ -118,18 +106,6 @@ class Loader(ABC): """Convert a PostgreSQL value to a Python object.""" ... - @classmethod - def register( - cls, oid: Union[int, str], context: Optional[AdaptContext] = None - ) -> None: - """ - Configure *context* to use this loader to convert values with OID *oid*. - """ - from . import postgres - - adapters = context.adapters if context else postgres.adapters - adapters.register_loader(oid, cls) - Transformer: Type["proto.Transformer"]