Skip to content

fix(cli): handle unparameterized list/dict annotations in value parser - #607

Open
ManoharPaturi wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
ManoharPaturi:fix/type-parser-unparameterized-list-dict
Open

fix(cli): handle unparameterized list/dict annotations in value parser#607
ManoharPaturi wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
ManoharPaturi:fix/type-parser-unparameterized-list-dict

Conversation

@ManoharPaturi

Copy link
Copy Markdown

Fixes #606.

parse_list/parse_dict now check get_args(annotation) and return the literal-evaluated collection when the annotation has no type arguments (nothing to coerce to). _maybe_resolve_annotation returns unparameterized generics as-is instead of rebuilding List[...] from an empty args tuple.

That fixes the crash for x: list/x: dict, the Optional[list] Union crash, bare typing.List, and the silent Union[list, str] → '[1, 2]' string misparse.

Tests: 5 new, all fail on main, pass here; test/cli/test_cli_parser.py fully green (85 passed).

Copilot AI lite review requested due to automatic review settings September 7, 2026 06:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…rser

parse_list and parse_dict unconditionally indexed get_args(annotation),
so any unparameterized collection annotation crashed the CLI parser:

- def f(tags: list) + tags=[1, 2, 3] raised ListParseError
  ('tuple index out of range')
- def f(mapping: dict) + mapping={'a': 1} raised DictParseError
  ('not enough values to unpack')
- Optional[list]/Optional[dict] failed the same way through parse_union
- Union[list, str] silently fell through to str and returned the raw
  string '[1, 2]' instead of a list
- bare typing.List/typing.Dict additionally crashed in
  _maybe_resolve_annotation when rebuilding the generic from an empty
  args tuple

Unparameterized annotations now fall back to untyped literal parsing,
and _maybe_resolve_annotation returns them unchanged.

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
@ManoharPaturi
ManoharPaturi force-pushed the fix/type-parser-unparameterized-list-dict branch from 84c1a8f to 5f1bc0b Compare September 7, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants