fix(cli): handle unparameterized list/dict annotations in value parser - #607
Open
ManoharPaturi wants to merge 1 commit into
Open
Conversation
…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
force-pushed
the
fix/type-parser-unparameterized-list-dict
branch
from
September 7, 2026 16:36
84c1a8f to
5f1bc0b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #606.
parse_list/parse_dictnow checkget_args(annotation)and return the literal-evaluated collection when the annotation has no type arguments (nothing to coerce to)._maybe_resolve_annotationreturns unparameterized generics as-is instead of rebuildingList[...]from an empty args tuple.That fixes the crash for
x: list/x: dict, theOptional[list]Union crash, baretyping.List, and the silentUnion[list, str] → '[1, 2]'string misparse.Tests: 5 new, all fail on main, pass here;
test/cli/test_cli_parser.pyfully green (85 passed).