fix(cli): handle unparameterized list/dict annotations in value parser by ManoharPaturi · Pull Request #607 · NVIDIA-NeMo/Run · GitHub
Skip to content

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

Merged
ko3n1g merged 2 commits into
NVIDIA-NeMo:mainfrom
ManoharPaturi:fix/type-parser-unparameterized-list-dict
Oct 2, 2026
Merged

ko3n1g merged 2 commits into
NVIDIA-NeMo:mainfrom
ManoharPaturi:fix/type-parser-unparameterized-list-dict

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

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
@copy-pr-bot

copy-pr-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

@ko3n1g

ko3n1g commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

@ko3n1g
ko3n1g enabled auto-merge (squash) October 2, 2026 16:21
@ko3n1g
ko3n1g merged commit c7dd080 into NVIDIA-NeMo:main Oct 2, 2026
22 checks passed
ManoharPaturi added a commit to ManoharPaturi/Run that referenced this pull request Oct 2, 2026
Resolve the cli_parser conflict by keeping this branch's resolver
helpers (_get_type_checking_imports, _resolve_string_annotation) and
folding main's NVIDIA-NeMo#607 unparameterized-generics early return into
_maybe_resolve_annotation.

Also address the review finding on forward references: a quoted name
under future annotations ("'Path'") evaluates to another string, and
container annotations like list["Path"] evaluate to generics holding
unresolved ForwardRefs. _resolve_string_annotation now feeds its
evaluated result back through _maybe_resolve_annotation (depth capped)
instead of stopping after one evaluation, and Literal args are skipped
by the recursion so Literal["Path"] keeps its string values. Added
regressions for the real future-annotations module, nested forward
refs, Literal preservation, and class-based configs.

This branch was successfully deployed

1 active deployment
public — d590d77b Deployed Oct 2, 2026 by copy-pr-bot[bot] via release / finalize / publish-docs #326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

3 participants