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

fix(serialization): Fix deserialization with typename aliases #20

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ezserialization"
version = "0.5.1"
version = "0.5.2"
description = "Simple, easy to use & transparent python objects serialization & deserialization."
authors = ["Matas Gumbinas <[email protected]>"]
repository = "https://github.com/gMatas/ezserialization"
Expand Down
4 changes: 2 additions & 2 deletions src/ezserialization/_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ def deserialize(src: Mapping) -> Serializable:
typename = src[type_field_name]
assert isinstance(typename, str), f"`typename` must be a string! Received {type(typename)=}"

typename_alias = None
if typename not in _types_:
typename_alias = None
if typename in _typename_aliases_:
typename_alias = typename
typename = _typename_aliases_[typename]
Expand All @@ -231,6 +231,6 @@ def deserialize(src: Mapping) -> Serializable:
err_msg += f" ({typename_alias=})"
raise ImportError(err_msg)

cls = _types_[typename]
cls = _types_[typename if typename_alias is None else typename_alias]
obj = cls.from_dict(src)
return obj
Loading