def METHOD_NAME(
    self, flags: Mapping[str, Any], replace_underscores: bool = False
) -> Mapping[str, Any]:
    """Reformats arguments that are easier to express as a list into the format that dbt expects,
    and deletes and keys with no value.
    """
    # remove any keys with a value of None
    if replace_underscores:
        flags = {k.replace("_", "-"): v for k, v in flags.items() if v is not None}
    else:
        flags = {k: v for k, v in flags.items() if v is not None}
    for param in ["select", "exclude", "models"]:
        if param in flags:
            if isinstance(flags[param], list):
                # if it's a list, format as space-separated
                flags[param] = " ".join(set(flags[param]))
    return flags