@@ -167,6 +167,9 @@ def __init__(
167167 if cli_hide_none_type is not None
168168 else settings_cls .model_config .get ('cli_hide_none_type' , False )
169169 )
170+ self .cli_parse_args = (
171+ cli_parse_args if cli_parse_args is not None else settings_cls .model_config .get ('cli_parse_args' , None )
172+ )
170173 self .cli_avoid_json = (
171174 cli_avoid_json if cli_avoid_json is not None else settings_cls .model_config .get ('cli_avoid_json' , False )
172175 )
@@ -247,15 +250,14 @@ def __init__(
247250 add_subparsers_method = add_subparsers_method ,
248251 formatter_class = formatter_class ,
249252 )
250-
251- if cli_parse_args not in (None , False ):
252- if cli_parse_args is True :
253- cli_parse_args = sys .argv [1 :]
254- elif not isinstance (cli_parse_args , (list , tuple )):
253+ if self .cli_parse_args not in (None , False ):
254+ if self .cli_parse_args is True :
255+ self .cli_parse_args = sys .argv [1 :]
256+ elif not isinstance (self .cli_parse_args , (list , tuple )):
255257 raise SettingsError (
256- f'cli_parse_args must be a list or tuple of strings, received { type (cli_parse_args )} '
258+ f'cli_parse_args must be a list or tuple of strings, received { type (self . cli_parse_args )} '
257259 )
258- self ._load_env_vars (parsed_args = self ._parse_args (self .root_parser , cli_parse_args ))
260+ self ._load_env_vars (parsed_args = self ._parse_args (self .root_parser , self . cli_parse_args ))
259261
260262 @overload
261263 def __call__ (self ) -> dict [str , Any ]: ...
0 commit comments