from typing import Set


def bits_to_candidates(bits: int) -> Set[int]:
    """
    Convert a bits representation into a set of candidates

    >>> bits_to_candidates(0b111)
    {1, 2, 3}

    >>> bits_to_candidates(0b111000101)
    {1, 3, 7, 8, 9}
    """
    candidates = set()
    i = 1
    while bits:
        bit = bits & 1
        if bit:
            candidates.add(i)

        bits >>= 1
        i += 1

    return candidates