File tree 3 files changed +22
-2
lines changed
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
12
12
paths are considered internals and can change in minor and patch releases.
13
13
14
14
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
+
15
24
v4.37.0 (2025-02-14)
16
25
--------------------
17
26
Original file line number Diff line number Diff line change @@ -546,7 +546,7 @@ def _create_group_if_requested(
546
546
if config_load and nested_key is not None :
547
547
group .add_argument ("--" + nested_key , action = _ActionConfigLoad (basetype = config_load_type ))
548
548
if inspect .isclass (obj ) and nested_key is not None and instantiate :
549
- group .dest = nested_key
549
+ group .dest = nested_key . replace ( "-" , "_" )
550
550
group .group_class = obj
551
551
group .instantiate_class = group_instantiate_class
552
552
return group
Original file line number Diff line number Diff line change @@ -243,7 +243,18 @@ def test_add_class_implemented_with_new(parser):
243
243
244
244
class RequiredParams :
245
245
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
247
258
248
259
249
260
def test_add_class_with_required_parameters (parser ):
You can’t perform that action at this time.
0 commit comments