Skip to content

Commit

Permalink
Improve metaclass __call__ method
Browse files Browse the repository at this point in the history
  • Loading branch information
citrux committed Oct 21, 2020
1 parent a7a15d4 commit e34ca07
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion joey/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ def get(self, key: Any, default: Any = None):


class SerializerMetaclass(ModelMetaclass):
def __call__(cls, obj):
def __call__(cls, obj=None, **kwargs):
if obj is None:
return super(SerializerMetaclass, cls).__call__(**kwargs)
if isinstance(obj, dict):
return cls.parse_obj(obj)
return cls.from_orm(obj)


Expand Down

0 comments on commit e34ca07

Please sign in to comment.