from typing import Iterable
from typing import Hashable
from typing import Set


def to_set(
        iterable: Iterable[Hashable]
) -> Set[Hashable]:
    """
    Convert iterable to set.

    If elements of the iterable are also iterable (may not be hashable),
    they will be converted to tuples.

    :param iterable: Iterable.

    :returns: Resulting set.

    .. note:: This is convenient for use with `@pytest.mark.parametrize`.
    """
    result = set()
    for each in iterable:
        if isinstance(each, Hashable):
            result.add(each)

        else:
            result.add(tuple(each))

    return result