NVIDIA-NeMo / NVIDIA-NeMo/Run

CLI parser crashes on unparameterized list/dict annotations (x: list); Union[list, str] silently misparses to string

Open
#606 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

community-request waiting-on-maintainers
Dominant language
Python
Stars
258
Forks
113
Avg merge
1d 3h
Merged PRs (30d)
5

Description

Description

Entry points using unparameterized collection annotations cannot be set from the CLI:

  • def f(tags: list) + tags=[1, 2, 3]ListParseError: Invalid list: tuple index out of range
  • def f(mapping: dict) + mapping={'a': 1}DictParseError: Invalid dict: not enough values to unpack
  • Optional[list] / Optional[dict] fail the same way through the Union parser
  • bare typing.List / typing.Dict crash with IndexError in _maybe_resolve_annotation
  • silent misparse: Union[list, str] with value [1, 2] returns the string '[1, 2]' because the failed list parse makes the Union fall through to str
Steps to reproduce
import nemo_run as run

@run.cli.entrypoint(skip_confirmation=True)
def train(tags: list = None):
    print(tags)

if __name__ == "__main__":
    run.cli.main(train)
$ python app.py tags=[1,2,3]
nemo_run.cli.cli_parser.ListParseError: ... Invalid list: tuple index out of range
Expected behavior

tags parses to the list [1, 2, 3] (no element type known → no coercion), matching Python semantics of bare list/dict.

Actual behavior

parse_list/parse_dict index get_args(annotation) unconditionally; get_args(list) is empty, so parsing crashes (or misparses inside a Union).

#558 was a different defect in the same area (PEP-604 dispatch) — these still reproduce on current main.

Environment

nemo-run main (b85eb67), Python 3.12, macOS

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CLI entry point in the reproduction and inspect parse_list, parse_dict, and _maybe_resolve_annotation, along with the Union parser. Run the provided Python 3.12 reproduction for bare list, dict, Optional, and Union annotations. Done means bare collections parse without coercion, Optional cases work, and Union[list, str] does not silently fall through to string.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.