from typing import Collection
from typing import Callable
from typing import Tuple


def key_func_for_attribute_multi(
    attributes: Collection[str],
) -> Callable[
    ...,
    Tuple[Tuple[str, str], ...],
]:
    """ Return a closure that given a slave, will return the value of a list of
    attributes, compiled into a hashable tuple

    :param attributes: the attribues to inspect in the slave
    :returns: a closure, which takes a slave and returns the value of those attributes
    """
    def get_attribute(slave, attribute):
        if attribute == "hostname":
            return slave["hostname"]
        else:
            return slave["attributes"].get(attribute, 'unknown')

    def key_func(slave):
        return tuple((a, get_attribute(slave, a)) for a in attributes)
    return key_func