import typing


def check_for_duplicate_keys(
    ordered_pairs: typing.List[typing.Tuple[typing.Hashable, typing.Any]]
) -> typing.Dict:
    """Check for duplicated keys.

    Raise ValueError if a duplicate key exists in provided ordered
    list of pairs, otherwise return a dict.

    Taken from https://stackoverflow.com/a/49518779/2750114 .
    """
    dict_out: typing.Dict = {}
    for key, val in ordered_pairs:
        if key in dict_out:
            raise ValueError(f"Duplicate key: {key}")
        else:
            dict_out[key] = val
    return dict_out