from typing import Iterator
from typing import Tuple
from typing import Any


def _duplicate_avoiding_dict(pairs: Iterator[Tuple[Any, Any]]):
    """
    The default output_type of CollectionParser.delimited_pairwise. Returns a dict from key-value pairs while
     ensuring there are no duplicate keys.
    """
    ret = {}
    for k, v in pairs:
        if k in ret:
            raise ValueError(f'duplicate key {k}')
        ret[k] = v
    return ret