Skip to content

Commit eb94c25

Browse files
committed
block incompatible adapter settings
1 parent 39124b7 commit eb94c25

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

key-value/key-value-shared/src/key_value/shared/utils/serialization.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from datetime import datetime
1010
from typing import Any, Literal, TypeVar
1111

12-
from key_value.shared.errors import DeserializationError
12+
from key_value.shared.errors import DeserializationError, SerializationError
1313
from key_value.shared.utils.managed_entry import ManagedEntry, dump_to_json, load_from_json, verify_dict
1414

1515
T = TypeVar("T")
@@ -130,6 +130,9 @@ def dump_dict(self, entry: ManagedEntry, exclude_none: bool = True) -> dict[str,
130130

131131
def dump_json(self, entry: ManagedEntry, exclude_none: bool = True) -> str:
132132
"""Convert a ManagedEntry to a JSON string."""
133+
if self._date_format == "datetime":
134+
msg = 'dump_json is incompatible with date_format="datetime"; use date_format="isoformat" or dump_dict().'
135+
raise SerializationError(msg)
133136
return dump_to_json(obj=self.dump_dict(entry=entry, exclude_none=exclude_none))
134137

135138

0 commit comments

Comments
 (0)