def load ( obj , cls , default_factory ) : if obj is None : return default_factory ( ) if isinstance ( obj , dict ) : return cls . load ( obj ) return obj
python load default value based on type
Create or load an object if necessary .
def load(obj, cls, default_factory):
    """Create or load an object if necessary.

    Parameters
    ----------
    obj : `object` or `dict` or `None`
    cls : `type`
    default_factory : `function`

    Returns
    -------
    `object`
    """
    if obj is None:
        return default_factory()
    if isinstance(obj, dict):
        return cls.load(obj)
    return obj