diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f35dd60..ef2a548 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,14 @@ Changelog ========= +Version 0.31.2 (2024-01-24) +--------------------------- + +Bugs fixed: + +- broken support for `Optional[List]` (but not `Optional[list]`), a narrower + case of the problem fixed earlier (issue #216). + Version 0.31.1 (2024-01-19) --------------------------- diff --git a/pyproject.toml b/pyproject.toml index 00db708..90f9f80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "argh" -version = "0.31.1" +version = "0.31.2" description = "Plain Python functions as CLI commands without boilerplate" readme = "README.rst" requires-python = ">=3.8" @@ -59,10 +59,10 @@ test = [ "pytest-cov >= 4.1", ] docs = [ - "sphinx >= 6.1", - "sphinx-pyproject == 0.1.0", - "sphinx_rtd_theme >= 1.2.0", - "readthedocs-sphinx-search == 0.2.0", + "sphinx >= 7.2", + "sphinx-pyproject == 0.3", + "sphinx_rtd_theme >= 2.0", + "readthedocs-sphinx-search == 0.3.2", ] linters = [ "pre-commit >= 3.4.0", diff --git a/src/argh/assembling.py b/src/argh/assembling.py index 02aefe5..7a690ea 100644 --- a/src/argh/assembling.py +++ b/src/argh/assembling.py @@ -770,10 +770,10 @@ def typing_hint_to_arg_spec_params( if first_subtype in cls.BASIC_TYPES: retval["type"] = first_subtype - if first_subtype == list: + if first_subtype in (list, List): retval["nargs"] = ZERO_OR_MORE - if get_origin(first_subtype) == list: + if first_subtype != List and get_origin(first_subtype) == list: retval["nargs"] = ZERO_OR_MORE item_type = cls._extract_item_type_from_list_type(first_subtype) if item_type: diff --git a/tests/test_typing_hints.py b/tests/test_typing_hints.py index 2432824..6114edc 100644 --- a/tests/test_typing_hints.py +++ b/tests/test_typing_hints.py @@ -36,6 +36,7 @@ def test_list(): assert guess(list) == {"nargs": "*"} assert guess(List) == {"nargs": "*"} assert guess(Optional[list]) == {"nargs": "*", "required": False} + assert guess(Optional[List]) == {"nargs": "*", "required": False} assert guess(List[str]) == {"nargs": "*", "type": str} assert guess(List[int]) == {"nargs": "*", "type": int}