from typing import Iterable
from typing import List


def unique_by(pairs: Iterable[tuple]) -> List:
    """Return a list of items with distinct keys. pairs yields (item, key)."""
    # return a list rather than a set, because items might not be hashable
    return list({key: item for item, key in pairs}.values())