Skip to content

RunContext.cli_command assigns the short flag -y to both --yaml and --yes — click warns on every invocation #559

Description

@mgrbyte

Summary

In RunContext.cli_command (nemo_run/cli/api.py, v0.9.0) two options claim the same short flag:

yaml: Optional[str] = typer.Option(None, "--yaml", "-y", help="Path to a YAML file to load"),        # L894
skip_confirmation: bool = typer.Option(False, "--yes", "-y", "--no-confirm", help="Skip confirmation before execution"),  # L899

so every invocation of any generated command prints:

UserWarning: The parameter -y is used more than once. Remove its duplicate as parameters should be unique.

(twice per parse: click/core.py make_parser and parse_args). Besides the noise, whichever option click resolves -y to wins silently — a user typing -y for "yes" may instead set yaml.

Minimal reproduction (nemo_run + typer only)

import warnings
import typer
from typer.testing import CliRunner
from nemo_run.cli.api import RunContext

def demo(x: int = 1) -> None:
    pass

app = typer.Typer()
RunContext.cli_command(app, "demo", demo)

with warnings.catch_warnings(record=True) as caught:
    warnings.simplefilter("always")
    CliRunner().invoke(app, ["demo", "--help"])

print(len([w for w in caught if "-y" in str(w.message)]))   # 4

Suggested fix

Drop -y from --yaml (the near-universal CLI convention reserves -y for yes/skip-confirmation), leaving --yaml long-form only.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions