def METHOD_NAME(inventory_filename: str):
    # fallback to INI if no extension
    extension = inventory_filename.split(".")[-1] if "." in inventory_filename else "ini"
    # host:set(groups) mapping
    host_to_groups = {}
    if extension in ["ini"]:
        host_to_groups = parse_inventory_ini(inventory_filename)
    elif extension in ["json"]:
        with open(inventory_filename, encoding="utf-8") as inventory_file:
            inventory_tree = json.load(inventory_file)
            # close file early
        host_to_groups = parse_inventory_tree(inventory_tree)
    elif extension in ["yaml", "yml"]:
        if yaml is None:
            raise Exception(
                (
                    "To parse YAML Ansible inventories requires `pyyaml`. "
                    "Install it with `pip install pyyaml`."
                ),
            )
        with open(inventory_filename, encoding="utf-8") as inventory_file:
            inventory_tree = yaml.safe_load(inventory_file)
            # close file early
        host_to_groups = parse_inventory_tree(inventory_tree)
    else:
        raise InventoryError(("Ansible inventory file format not supported: {0}").format(extension))
    return [(host, {}, sorted(list(host_to_groups.get(host, [])))) for host in host_to_groups]