def METHOD_NAME(
        results: dict[str, list[AURPackageInfo]],
        query: str,
        *,
        names_only: bool = False,
) -> dict[str, list[AURPackageInfo]]:
    filtered_results: dict[str, list[AURPackageInfo]] = {}
    for _q, pkgs in results.items():
        for pkg in pkgs:
            if (
                    query in pkg.name
            ) or (
                not names_only and
                (query in (pkg.desc or ""))
            ):
                filtered_results.setdefault(_q, []).append(pkg)
    return filtered_results