@@ -953,6 +953,9 @@ def save_paths(cfg):
953953 ## Methods related to defaults ##
954954
955955 def _get_default_config_files (self ) -> List [Tuple [Optional [str ], Path ]]:
956+ if getattr (self , "_inner_parser" , False ):
957+ return []
958+
956959 default_config_files = []
957960
958961 for key , parser in parent_parsers .get ():
@@ -1022,7 +1025,7 @@ def get_defaults(self, skip_validation: bool = False, **kwargs) -> Namespace:
10221025 if not default_config_file_content .strip ():
10231026 continue
10241027 with change_to_path_dir (default_config_file ), parser_context (parent_parser = self ):
1025- cfg_file = self ._load_config_parser_mode (default_config_file . get_content () , key = key )
1028+ cfg_file = self ._load_config_parser_mode (default_config_file_content , key = key , prev_cfg = cfg )
10261029 cfg = self .merge_config (cfg_file , cfg )
10271030 try :
10281031 with _ActionPrintConfig .skip_print_config ():
@@ -1365,11 +1368,15 @@ def _apply_actions(
13651368 continue
13661369
13671370 action_dest = action .dest if subcommand is None else subcommand + "." + action .dest
1371+ append = False
1372+ if action_dest not in cfg and key .endswith ("+" ):
1373+ append = True
1374+ cfg [action_dest ] = cfg .pop (key )
13681375 value = cfg [action_dest ]
13691376 if skip_fn and skip_fn (value ):
13701377 continue
13711378 with parser_context (parent_parser = self , lenient_check = True ):
1372- value = self ._check_value_key (action , value , action_dest , prev_cfg )
1379+ value = self ._check_value_key (action , value , action_dest , prev_cfg , append = append )
13731380 if isinstance (action , _ActionConfigLoad ):
13741381 config_keys .add (action_dest )
13751382 keys .append (action_dest )
@@ -1393,10 +1400,11 @@ def merge_config(self, cfg_from: Namespace, cfg_to: Namespace) -> Namespace:
13931400 with parser_context (parent_parser = self ):
13941401 ActionTypeHint .discard_init_args_on_class_path_change (self , cfg_to , cfg_from )
13951402 cfg_to .update (cfg_from )
1396- ActionTypeHint .apply_appends (self , cfg_to )
13971403 return cfg_to
13981404
1399- def _check_value_key (self , action : argparse .Action , value : Any , key : str , cfg : Optional [Namespace ]) -> Any :
1405+ def _check_value_key (
1406+ self , action : argparse .Action , value : Any , key : str , cfg : Optional [Namespace ], append : bool = False
1407+ ) -> Any :
14001408 """Checks the value for a given action.
14011409
14021410 Args:
@@ -1421,7 +1429,7 @@ def _check_value_key(self, action: argparse.Action, value: Any, key: str, cfg: O
14211429 value = action .check_type (value , self )
14221430 elif hasattr (action , "_check_type" ):
14231431 with parser_context (parent_parser = self ):
1424- value = action ._check_type_ (value , cfg = cfg ) # type: ignore[attr-defined]
1432+ value = action ._check_type_ (value , cfg = cfg , append = append ) # type: ignore[attr-defined]
14251433 elif action .type is not None :
14261434 try :
14271435 if action .nargs in {None , "?" } or action .nargs == 0 :
0 commit comments