File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,15 @@ The semantic versioning only considers the public API as described in
1212paths are considered internals and can change in minor and patch releases.
1313
1414
15+ v4.37.1 (2025-02-??)
16+ --------------------
17+
18+ Fixed
19+ ^^^^^
20+ - ``add_class_arguments `` with dashes in the ``nested_key `` fail to instantiate
21+ (`#679 <https://github.com/omni-us/jsonargparse/pull/679 >`__).
22+
23+
1524v4.37.0 (2025-02-14)
1625--------------------
1726
Original file line number Diff line number Diff line change @@ -546,7 +546,7 @@ def _create_group_if_requested(
546546 if config_load and nested_key is not None :
547547 group .add_argument ("--" + nested_key , action = _ActionConfigLoad (basetype = config_load_type ))
548548 if inspect .isclass (obj ) and nested_key is not None and instantiate :
549- group .dest = nested_key
549+ group .dest = nested_key . replace ( "-" , "_" )
550550 group .group_class = obj
551551 group .instantiate_class = group_instantiate_class
552552 return group
Original file line number Diff line number Diff line change @@ -243,7 +243,18 @@ def test_add_class_implemented_with_new(parser):
243243
244244class RequiredParams :
245245 def __init__ (self , n : int , m : float ):
246- pass
246+ self .n = n
247+ self .m = m
248+
249+
250+ def test_add_class_group_name_dash_required_parameters (parser ):
251+ parser .add_class_arguments (RequiredParams , "required-params" )
252+ assert "required-params" in parser .groups
253+ cfg = parser .parse_args (["--required-params.n=6" , "--required-params.m=0.9" ])
254+ init = parser .instantiate_classes (cfg )
255+ assert isinstance (init .required_params , RequiredParams )
256+ assert init .required_params .n == 6
257+ assert init .required_params .m == 0.9
247258
248259
249260def test_add_class_with_required_parameters (parser ):
You can’t perform that action at this time.
0 commit comments