Skip to content

Commit

Permalink
fix: broken support for type alias List (fixes #216)
Browse files Browse the repository at this point in the history
  • Loading branch information
neithere committed Jan 19, 2024
1 parent e79048d commit 8f270d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.rst
@@ -1,9 +1,13 @@
Changelog
=========

Version 0.31.1 (TODO: DATE)
Version 0.31.1 (2024-01-19)
---------------------------

Bugs fixed:

- broken support for type alias `List` (issue #216).

Enhancements:

- cleaned up the README, rearranged other documentation.
Expand Down
2 changes: 1 addition & 1 deletion src/argh/assembling.py
Expand Up @@ -756,7 +756,7 @@ def typing_hint_to_arg_spec_params(
}

# `list`
if type_def == list:
if type_def in (list, List):
return {"nargs": ZERO_OR_MORE}

# `Literal["a", "b"]`
Expand Down
1 change: 1 addition & 0 deletions tests/test_typing_hints.py
Expand Up @@ -34,6 +34,7 @@ def test_list():
guess = TypingHintArgSpecGuesser.typing_hint_to_arg_spec_params

assert guess(list) == {"nargs": "*"}
assert guess(List) == {"nargs": "*"}
assert guess(Optional[list]) == {"nargs": "*", "required": False}

assert guess(List[str]) == {"nargs": "*", "type": str}
Expand Down

0 comments on commit 8f270d0

Please sign in to comment.