def METHOD_NAME(history: str):
    # Returns all previously listed PR numbers in HISTORY file
    match_groups = [r"\(#(=\d+)\)", r"\[\#(\d+)\]"]
    expr = re.compile("|".join(match_groups))
    # Flatten ('', '1234'). Only one group should ever match.
    existing_prs = [a+b for a,b in expr.findall(history)]
    return set(map(int, existing_prs))