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
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 parsertyping.List/typing.Dictcrash withIndexErrorin_maybe_resolve_annotationUnion[list, str]with value[1, 2]returns the string'[1, 2]'because the failed list parse makes the Union fall through tostrSteps to reproduce
Expected behavior
tagsparses to the list[1, 2, 3](no element type known → no coercion), matching Python semantics of barelist/dict.Actual behavior
parse_list/parse_dictindexget_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