Skip to content

Commit

Permalink
issue Fatal1ty#93: Fix custom serialization for two or more fields of…
Browse files Browse the repository at this point in the history
… the same type.
  • Loading branch information
peterallenwebb committed Jan 6, 2023
1 parent 7638180 commit 8409354
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion mashumaro/core/meta/code/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,6 @@ def iter_serialization_strategies(
yield metadata.get("serialization_strategy")
yield from self.__iter_serialization_strategies(ftype)

@lru_cache()
@typing.no_type_check
def __iter_serialization_strategies(
self, ftype: typing.Type
Expand Down
7 changes: 4 additions & 3 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def deserialize(self, value):
class DataClass(DataClassDictMixin):
a: int
b: str
c: int

class Config(BaseConfig):
serialization_strategy = {
Expand All @@ -152,9 +153,9 @@ class Config(BaseConfig):
},
}

instance = DataClass(a=123, b="abc")
assert DataClass.from_dict({"a": [123], "b": ["abc"]}) == instance
assert instance.to_dict() == {"a": [123], "b": ["abc"]}
instance = DataClass(a=123, b="abc", c=123)
assert DataClass.from_dict({"a": [123], "b": ["abc"], "c": [123]}) == instance
assert instance.to_dict() == {"a": [123], "b": ["abc"], "c": [123]}


def test_named_tuple_as_dict():
Expand Down

0 comments on commit 8409354

Please sign in to comment.