File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 38
38
RequestHeaders ,
39
39
)
40
40
41
- T = TypeVar ("T" )
42
- U = TypeVar ("U" )
43
- V = TypeVar ("V" )
41
+ T = TypeVar ("T" ) # Serializer type
42
+ U = TypeVar ("U" ) # Deserializer loads
43
+ V = TypeVar ("V" ) # Deserializer loads_many
44
44
45
45
46
46
class Collection (Generic [T , U , V ]):
@@ -892,7 +892,7 @@ def response_handler(resp: Response) -> bool | Json:
892
892
893
893
async def get_many (
894
894
self ,
895
- documents : Sequence [str | Json ],
895
+ documents : Sequence [str | T ],
896
896
allow_dirty_read : Optional [bool ] = None ,
897
897
ignore_revs : Optional [bool ] = None ,
898
898
) -> Result [V ]:
@@ -925,14 +925,17 @@ async def get_many(
925
925
926
926
headers : RequestHeaders = {}
927
927
if allow_dirty_read is not None :
928
- headers ["x-arango-allow-dirty-read" ] = allow_dirty_read
928
+ if allow_dirty_read is True :
929
+ headers ["x-arango-allow-dirty-read" ] = "true"
930
+ else :
931
+ headers ["x-arango-allow-dirty-read" ] = "false"
929
932
930
933
request = Request (
931
934
method = Method .PUT ,
932
935
endpoint = f"/_api/document/{ self .name } " ,
933
936
params = params ,
934
937
headers = headers ,
935
- data = self .serializer .dumps (documents ),
938
+ data = self ._doc_serializer .dumps (documents ),
936
939
)
937
940
938
941
def response_handler (resp : Response ) -> V :
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class Serializer(ABC, Generic[T]): # pragma: no cover
26
26
"""
27
27
28
28
@abstractmethod
29
- def dumps (self , data : str | bool | T | Sequence [T | str ]) -> str :
29
+ def dumps (self , data : T | Sequence [T | str ]) -> str :
30
30
"""Serialize any generic data.
31
31
32
32
Args:
@@ -87,7 +87,7 @@ def loads_many(self, data: bytes) -> U:
87
87
class JsonSerializer (Serializer [Json ]):
88
88
"""JSON serializer."""
89
89
90
- def dumps (self , data : T ) -> str :
90
+ def dumps (self , data : Json | Sequence [ str | Json ] ) -> str :
91
91
try :
92
92
return json .dumps (data , separators = ("," , ":" ))
93
93
except Exception as e :
You can’t perform that action at this time.
0 commit comments