]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
feat: extend signature of Dumper.dump() to allow returning None
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 18 Sep 2022 23:36:35 +0000 (00:36 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 1 Jun 2024 11:07:21 +0000 (13:07 +0200)
psycopg/psycopg/abc.py
psycopg/psycopg/adapt.py

index 480fc064c7914cd265f4e093ca86363d7e00cd5e..11e10b161d0d76a57013a522b8af16d81f3377b6 100644 (file)
@@ -62,7 +62,7 @@ class WaitFunc(Protocol):
 
 # Adaptation types
 
-DumpFunc: TypeAlias = Callable[[Any], Buffer]
+DumpFunc: TypeAlias = Callable[[Any], Optional[Buffer]]
 LoadFunc: TypeAlias = Callable[[Buffer], Any]
 
 
@@ -110,7 +110,7 @@ class Dumper(Protocol):
 
     def __init__(self, cls: type, context: Optional[AdaptContext] = None): ...
 
-    def dump(self, obj: Any) -> Buffer:
+    def dump(self, obj: Any) -> Optional[Buffer]:
         """Convert the object `!obj` to PostgreSQL representation.
 
         :param obj: the object to convert.
index 7d6a191d8d68df009a9573a393bca0ad733259e1..4b33fbb672cde0c772adc54ee33d0a51daab6bfd 100644 (file)
@@ -46,7 +46,7 @@ class Dumper(abc.Dumper, ABC):
         )
 
     @abstractmethod
-    def dump(self, obj: Any) -> Buffer: ...
+    def dump(self, obj: Any) -> Optional[Buffer]: ...
 
     def quote(self, obj: Any) -> Buffer:
         """