import pickle


def read_usernames(username_path: str, current_username_set: set = set()) -> set:
    """reads usernames from a saved pickle. Also adds any locally added usernames if available.
    

    Args:
        username_path (str): path to the pickle file
        current_username_set DEFAULT -> set(): in case there was an exsisting set

    Returns:
        set: a set of lichess.org usernames
    """

    with open(username_path, "rb") as f:
        username_set = pickle.load(f)
    
    for i in current_username_set:
        username_set.add(i)

    return username_set