Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicate unknown type for deserialization. #8

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/pymodaq_utils/serialize/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def get_type_from_str(self, obj_type_str: str) -> type:
for k in self.serializable_registry:
if obj_type_str in str(k):
return k
raise ValueError("Unknown type")
raise ValueError(f"Unknown type '{obj_type_str}'")

def get_serializables(self) -> List[type]:
return list(self.serializable_registry.keys())
Expand All @@ -149,7 +149,7 @@ def get_serializer(self, obj_type: type) -> Serializer:
if entry_dict is not None:
return entry_dict['serializer'] # type: ignore
else:
raise NotImplementedError(f'There is no known method to serialize {obj_type}')
raise NotImplementedError(f"There is no known method to serialize '{obj_type}'")

def get_apply_serializer(self, obj: Any, append_length=False) -> bytes:
"""
Expand Down Expand Up @@ -189,7 +189,7 @@ def get_deserializer(self, obj_type: type[Serializable]) -> Deserializer[Seriali
if entry_dict is not None:
return entry_dict['deserializer'] # type: ignore
else:
raise NotImplementedError(f'There is no known method to deserialize an {obj_type} type')
raise NotImplementedError(f"There is no known method to deserialize an '{obj_type}' type")

def get_apply_deserializer(
self, bytes_str: bytes, only_object: bool = True
Expand Down Expand Up @@ -225,7 +225,7 @@ def get_apply_deserializer(

obj_type = self.get_type_from_str(obj_type_str)
if obj_type is None:
raise NotImplementedError(f'There is no known method to deserialize an {obj_type_str} '
f'type')
raise NotImplementedError(f"There is no known method to deserialize an "
f"'{obj_type_str}' type")
result = self.get_deserializer(obj_type)(remaining_bytes)
return result[0] if only_object else result