models: Simplify JSON decoder code
This commit is contained in:
parent
fb0e4dc7a1
commit
2cb2750b39
@ -313,13 +313,11 @@ def model_json_decoder(dct):
|
||||
|
||||
"""
|
||||
if '__model__' in dct:
|
||||
# TODO: move models to a global constant once we split this module
|
||||
models = {c.__name__: c for c in ImmutableObject.__subclasses__()}
|
||||
model_name = dct.pop('__model__')
|
||||
if model_name in models:
|
||||
kwargs = {}
|
||||
for key, value in dct.items():
|
||||
kwargs[key] = value
|
||||
return models[model_name](**kwargs)
|
||||
return models[model_name](**dct)
|
||||
return dct
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user