def get_signatures_for_func(func_value, func_name, locale, is_overload: bool = False, comment: Optional[str] = None):
    """Return the signatures for the given function, recursing as necessary to handle overloads."""
    signatures = []

    if comment is None:
        comment = inspect.getdoc(func_value)

    if not is_overload:
        try:
            overloads = get_overloads(func_value)
        except Exception as e:
            raise TypeError(f"Can't parse overloads for {func_name}{sig}.") from e

        if overloads:
            for overload in overloads:
                signatures.extend(
                    get_signatures_for_func(overload, func_name, locale, is_overload=True, comment=comment)
                )
            return signatures

    sig = inspect.signature(func_value)
    try:
        hints = get_type_hints(func_value)
    except Exception as e:
        raise TypeError(f"Can't parse {func_name}{sig}.") from e
    ret_annot_module = getattr(sig.return_annotation, "__module__", None)
    if sig.return_annotation not in [
        None,
        inspect.Signature.empty,
        prov_cls.__name__,
    ] and ret_annot_module not in [
        None,
        *BUILTIN_MODULES_TO_IGNORE,
    ]:
        module, member = get_module_and_member_to_import(sig.return_annotation, locale)
        if module not in [None, "types"]:
            if imports[module] is None:
                imports[module] = set() if member is None else {member}
            elif member is not None:
                imports[module].add(member)

    new_parms = []
    for key, parm_val in sig.parameters.items():
        new_parm = parm_val
        annotation = hints.get(key, new_parm.annotation)
        if parm_val.default is not inspect.Parameter.empty:
            new_parm = parm_val.replace(default=...)
        if annotation is not inspect.Parameter.empty and annotation.__module__ not in BUILTIN_MODULES_TO_IGNORE:
            module, member = get_module_and_member_to_import(annotation, locale)
            if module not in [None, "types"]:
                if imports[module] is None:
                    imports[module] = set() if member is None else {member}
                elif member is not None:
                    imports[module].add(member)
        new_parms.append(new_parm)

    sig = sig.replace(parameters=new_parms)
    sig_str = str(sig).replace("Ellipsis", "...").replace("NoneType", "None").replace("~", "")
    for module in imports.keys():
        if module in MODULES_TO_FULLY_QUALIFY:
            continue
        sig_str = sig_str.replace(f"{module}.", "")

    decorator = ""
    if is_overload:
        decorator += "@overload\n"
    if list(sig.parameters)[0] == "cls":
        decorator += "@classmethod\n"
    elif list(sig.parameters)[0] != "self":
        decorator += "@staticmethod\n"
    signatures.append(
        (
            f"{decorator}def {func_name}{sig_str}: ...",
            None if comment == "" else comment,
            False,
        )
    )
    return signatures
Return the signatures for the given function, recursing as necessary to handle overloads.
generate_stubs.py