From 8f270d01c6ce8c8571a5c5055de2f78273eba094 Mon Sep 17 00:00:00 2001 From: Andy Mikhaylenko Date: Fri, 19 Jan 2024 17:39:48 +0100 Subject: [PATCH] fix: broken support for type alias List (fixes #216) --- CHANGELOG.rst | 6 +++++- src/argh/assembling.py | 2 +- tests/test_typing_hints.py | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 330f520..f35dd60 100644 --- a/CHANGELOG.rst +++ b/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. diff --git a/src/argh/assembling.py b/src/argh/assembling.py index a7860d7..02aefe5 100644 --- a/src/argh/assembling.py +++ b/src/argh/assembling.py @@ -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"]` diff --git a/tests/test_typing_hints.py b/tests/test_typing_hints.py index 1b02da7..2432824 100644 --- a/tests/test_typing_hints.py +++ b/tests/test_typing_hints.py @@ -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}