@@ -198,7 +198,7 @@ def _(_: PrimitiveType, value_str: str) -> bytes:
198198
199199@singledispatch
200200def to_bytes (
201- primitive_type : PrimitiveType , _ : bool | bytes | Decimal | date | datetime | float | int | str | time | uuid .UUID
201+ primitive_type : PrimitiveType , value : bool | bytes | Decimal | date | datetime | float | int | str | time | uuid .UUID
202202) -> bytes :
203203 """Convert a built-in python value to bytes.
204204
@@ -208,10 +208,10 @@ def to_bytes(
208208
209209 Args:
210210 primitive_type (PrimitiveType): An implementation of the PrimitiveType base class.
211- _ : The value to convert to bytes (The type of this value depends on which dispatched function is
211+ value : The value to convert to bytes (The type of this value depends on which dispatched function is
212212 used--check dispatchable functions for type hints).
213213 """
214- raise TypeError (f"scale does not match { primitive_type } " )
214+ raise TypeError (f"Cannot serialize to bytes, type { primitive_type } not supported: { value !r } " )
215215
216216
217217@to_bytes .register (BooleanType )
@@ -408,7 +408,7 @@ def to_json(primitive_type: PrimitiveType, val: Any) -> L: # type: ignore
408408 primitive_type (PrimitiveType): An implementation of the PrimitiveType base class.
409409 val (Any): The arbitrary built-in value to convert into the right form
410410 """
411- raise TypeError (f"Cannot deserialize bytes , type { primitive_type } not supported: { val } " )
411+ raise TypeError (f"Cannot serialize to JSON , type { primitive_type } not supported: { val } " )
412412
413413
414414@to_json .register (BooleanType )
@@ -547,7 +547,7 @@ def from_json(primitive_type: PrimitiveType, val: Any) -> L: # type: ignore
547547 primitive_type (PrimitiveType): An implementation of the PrimitiveType base class.
548548 val (Any): The arbitrary JSON value to convert into the right form
549549 """
550- raise TypeError (f"Cannot deserialize bytes , type { primitive_type } not supported: { str ( val ) } " )
550+ raise TypeError (f"Cannot deserialize JSON , type { primitive_type } not supported: { val } " )
551551
552552
553553@from_json .register (BooleanType )
0 commit comments