def from_dict_hook(data):
    """Decode internal objects encoded using `to_dict_hook`.

    This automatically imports the class defined in the `_type` metadata field,
    and calls the `from_dict` method hook to instantiate an object of that
    class.

    Note:
        Because this function will do automatic module loading it's really
        important to only use this with sanitized or trusted input, otherwise
        arbitrary modules can be imported and potentially arbitrary code can be
        executed.
    """
    type_ = data.get('_type', None)
    if type_ is not None:
        klass = _import_type(type_)

        msg = '_type must point to a class with `from_dict` static method'
        assert hasattr(klass, 'from_dict'), msg

        return klass.from_dict(data)
    return data
def from_dict_hook ( data ) : type_ = data . get ( '_type' , None ) if type_ is not None : klass = _import_type ( type_ ) msg = '_type must point to a class with `from_dict` static method' assert hasattr ( klass , 'from_dict' ) , msg return klass . from_dict ( data ) return data
Decode internal objects encoded using `to_dict_hook`.

    This automatically imports the class defined in the `_type` metadata field,
    and calls the `from_dict` method hook to instantiate an object of that
    class.

    Note:
        Because this function will do automatic module loading it's really
        important to only use this with sanitized or trusted input, otherwise
        arbitrary modules can be imported and potentially arbitrary code can be
        executed.