Skip to content

Commit

Permalink
minor bump
Browse files Browse the repository at this point in the history
  • Loading branch information
rnag committed Nov 15, 2024
1 parent 06a0fd6 commit 5a0433e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dataclass_wizard/dumpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,9 @@ def dump_func_for_dataclass(cls: Type[T],
# In any case, save the dump function for the class, so we don't need to
# run this logic each time.
if is_main_class:
if hasattr(cls, 'to_dict'):
# Check if the class has a `to_dict`, and it's
# equivalent to `asdict`.
if getattr(cls, 'to_dict', None) is asdict:
_set_new_attribute(cls, 'to_dict', asdict_func)
_CLASS_TO_DUMP_FUNC[cls] = asdict_func
else:
Expand Down
5 changes: 4 additions & 1 deletion dataclass_wizard/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,10 @@ def load_func_for_dataclass(
# Save the load function for the main dataclass, so we don't need to run
# this logic each time.
if is_main_class:
if hasattr(cls, 'from_dict'):
# Check if the class has a `from_dict`, and it's
# a class method bound to `fromdict`.
if ((from_dict := getattr(cls, 'from_dict', None)) is not None
and getattr(from_dict, '__func__', None) is fromdict):
_set_new_attribute(cls, 'from_dict', cls_fromdict)
_CLASS_TO_LOAD_FUNC[cls] = cls_fromdict

Expand Down

0 comments on commit 5a0433e

Please sign in to comment.