def get_list(data_dict, key, optional=False):
    """
    Extract a list from a data_dict and do a bit of error checking
    """
    if key not in data_dict:
        if optional:
            return None
        else:
            raise ValueError('Key "{}" not present in data'.format(key))

    l = data_dict[key]  # noqa
    if not isinstance(l, list):
        raise ValueError('Key "{}" is not a list'.format(key))

    return l