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.37.1 (2025-02-??)
--------------------

Fixed
^^^^^
- ``add_class_arguments`` with dashes in the ``nested_key`` fail to instantiate
(`#679 <https://github.com/omni-us/jsonargparse/pull/679>`__).


v4.37.0 (2025-02-14)
--------------------

Expand Down
2 changes: 1 addition & 1 deletion jsonargparse/_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def _create_group_if_requested(
if config_load and nested_key is not None:
group.add_argument("--" + nested_key, action=_ActionConfigLoad(basetype=config_load_type))
if inspect.isclass(obj) and nested_key is not None and instantiate:
group.dest = nested_key
group.dest = nested_key.replace("-", "_")
group.group_class = obj
group.instantiate_class = group_instantiate_class
return group
Expand Down
13 changes: 12 additions & 1 deletion jsonargparse_tests/test_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,18 @@ def test_add_class_implemented_with_new(parser):

class RequiredParams:
def __init__(self, n: int, m: float):
pass
self.n = n
self.m = m


def test_add_class_group_name_dash_required_parameters(parser):
parser.add_class_arguments(RequiredParams, "required-params")
assert "required-params" in parser.groups
cfg = parser.parse_args(["--required-params.n=6", "--required-params.m=0.9"])
init = parser.instantiate_classes(cfg)
assert isinstance(init.required_params, RequiredParams)
assert init.required_params.n == 6
assert init.required_params.m == 0.9


def test_add_class_with_required_parameters(parser):
Expand Down
Loading