Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ The semantic versioning only considers the public API as described in
paths are considered internals and can change in minor and patch releases.


v4.33.3 (2024-10-??)
--------------------

Fixed
^^^^^
- Empty tuples are now parsed correctly instead of raising an error.
(`#592 <https://github.com/omni-us/jsonargparse/pull/592`__).


v4.33.2 (2024-10-07)
--------------------

Expand Down
2 changes: 0 additions & 2 deletions jsonargparse/_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,6 @@ def adapt_typehints(
for n, v in enumerate(val):
subtypehint = subtypehints[0 if is_ellipsis or not is_tuple else n]
val[n] = adapt_typehints(v, subtypehint, **adapt_kwargs)
if is_tuple and len(val) == 0:
raise_unexpected_value("Expected a non-empty tuple", val)
if not serialize:
val = tuple(val) if typehint_origin in {Tuple, tuple} else set(val)

Expand Down
2 changes: 1 addition & 1 deletion jsonargparse_tests/test_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def test_tuple_ellipsis(parser):
parser.add_argument("--tuple", type=Tuple[float, ...])
assert (1.2,) == parser.parse_args(["--tuple=[1.2]"]).tuple
assert (1.2, 3.4) == parser.parse_args(["--tuple=[1.2, 3.4]"]).tuple
pytest.raises(ArgumentError, lambda: parser.parse_args(["--tuple=[]"]))
assert () == parser.parse_args(["--tuple=[]"]).tuple
pytest.raises(ArgumentError, lambda: parser.parse_args(['--tuple=[2, "a"]']))


Expand Down
Loading