From: Denis Laxalde Date: Thu, 10 Jun 2021 11:27:05 +0000 (+0200) Subject: Make Composable an abstract base class X-Git-Tag: 3.0.dev0~24^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d4b399390f8808eb9063242ce901a643c4305e1e;p=thirdparty%2Fpsycopg.git Make Composable an abstract base class --- diff --git a/psycopg3/psycopg3/sql.py b/psycopg3/psycopg3/sql.py index 9b7ac125e..3ac75f54b 100644 --- a/psycopg3/psycopg3/sql.py +++ b/psycopg3/psycopg3/sql.py @@ -6,6 +6,7 @@ SQL composition utility module import codecs import string +from abc import ABC, abstractmethod from typing import Any, Iterator, List, Optional, Sequence, Union from .pq import Escaping @@ -29,7 +30,7 @@ def quote(obj: Any, context: Optional[AdaptContext] = None) -> str: return Literal(obj).as_string(context) -class Composable: +class Composable(ABC): """ Abstract base class for objects that can be used to compose an SQL string. @@ -50,6 +51,7 @@ class Composable: def __repr__(self) -> str: return f"{self.__class__.__name__}({self._obj!r})" + @abstractmethod def as_bytes(self, context: Optional[AdaptContext]) -> bytes: """ Return the value of the object as bytes.