CLI parser crashes on unparameterized list/dict annotations (x: list); Union[list, str] silently misparses to string
Nobody has claimed this yet.
- 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 rangedef f(mapping: dict)+mapping={'a': 1}→DictParseError: Invalid dict: not enough values to unpackOptional[list]/Optional[dict]fail the same way through the Union parser- bare
typing.List/typing.Dictcrash withIndexErrorin_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 tostr
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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