from typing import List
from typing import Dict
from typing import Optional
from typing import Set


def get_distinct_attribute_values_from_dict(
    attribute_name: str,
    entry_dicts: List[Dict],
    is_single_value_column: Optional[bool] = False,
) -> Set[str]:
    """Function to get the distinct attribute values from a list of dicts

    Args:
        attribute_name: Attribute to extract the distinct values from
        entry_dicts: List of dictionaries with wikidata entities mapped to oab entities
        is_single_value_column: Modus either extract a single value or a list of values. Defaults to False.

    Returns:
        A set of distinct string values e. g. qids
    """
    attribute_set = set()
    for json_object in entry_dicts:
        if is_single_value_column:
            value = json_object[attribute_name]
            if value != "":
                attribute_set.add(value)
        else:
            for values in json_object[attribute_name]:
                attribute_set.add(values)

    return attribute_set