def parse_field(field, field_name):
    """Parse field according to field type.

    Parameters
    ----------
    field: str, dict
        field to be parsed. When a dictionary is given, it will return it
        as is. When a string is provided it will return the eval version
        of it, in order to return a dict
    field_name: str
        name of the field to be parsed. It is displayed in the error message
        when the field type is not valid.

    """
    if isinstance(field, dict):
        return field

    if isinstance(field, str):
        return eval(field)

    raise ValueError(f'Unexpected value for {field_name}')