File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -391,9 +391,14 @@ def _traverse_sub(
391391 variant_hook : HookVrntType = _DUMMYHOOK ,
392392 path : list [str ] | None = None ,
393393 ):
394- assert isinstance (value , dict )
395394 if path is None :
396395 path = [self .name ]
396+ if not isinstance (value , dict ):
397+ raise ArgumentTypeError (
398+ path ,
399+ f"key `{ path [- 1 ]} ` gets wrong value type, "
400+ f"requires dict but { type (value ).__name__ } is given" ,
401+ )
397402 sub_hook (self , value , path )
398403 for subvrnt in self .sub_variants .values ():
399404 variant_hook (subvrnt , value , path )
Original file line number Diff line number Diff line change @@ -156,6 +156,14 @@ def test_sub_repeat_dict(self):
156156 }
157157 with self .assertRaises (ArgumentTypeError ):
158158 ca .check (err_dict2 )
159+ err_dict3 = {
160+ "base" : {
161+ "item1" : {"sub1" : 10 , "sub2" : "hello" },
162+ "item2" : "not_a_dict_error" ,
163+ }
164+ }
165+ with self .assertRaises (ArgumentTypeError ):
166+ ca .check (err_dict3 )
159167
160168 def test_sub_variants (self ):
161169 ca = Argument (
You can’t perform that action at this time.
0 commit comments