class documentation

Drop-in replacement for argparse.ArgumentParser that adds support for environment variables and .ini or .yaml-style config files.

Method __init__ Supports args of the argparse.ArgumentParser constructor as **kwargs, as well as the following additional args.
Method convert_item_to_command_line_arg Converts a config file or env var key + value to a list of commandline args to append to the commandline.
Method format_help Undocumented
Method format_values Returns a string with all args and settings and where they came from (eg. commandline, config file, environment variable or default)
Method get_command_line_key_for_unknown_config_file_setting Compute a commandline arg key to be used for a config file setting that doesn't correspond to any defined configargparse arg (and so doesn't have a user-specified commandline arg key).
Method get_items_for_config_file_output Converts the given settings back to a dictionary that can be passed to ConfigFileParser.serialize(..).
Method get_possible_config_keys This method decides which actions can be set in a config file and what their keys will be. It returns a list of 0 or more config keys that can be used to set the given action's value in a config file.
Method get_source_to_settings_dict If called after parse_args() or parse_known_args(), returns a dict whose keys say where values came from, each mapped to a dict of the settings from there:
Method parse_args Supports all the same args as the argparse.ArgumentParser.parse_args(), as well as the following additional args.
Method parse_intermixed_args Like parse_args(), but lets optional and positional args be intermixed, as argparse.ArgumentParser.parse_intermixed_args() does.
Method parse_known_args Supports all the same args as the argparse.ArgumentParser.parse_args(), as well as the following additional args.
Method parse_known_intermixed_args Like parse_known_args(), but lets optional and positional args be intermixed, as argparse.ArgumentParser.parse_known_intermixed_args() does.
Method print_values Prints the format_values() string (to sys.stdout or another file).
Method write_config_file Write the given settings to output files.
Instance Variable exit_on_error Undocumented
Method _add_args_from_source Turn the settings from one config file or the env vars into args.
Method _arg_is_an_option_that_takes_every_later_arg Check whether an arg names an option with nargs=REMAINDER.
Method _arg_is_read_as_an_option Check whether argparse reads a command line arg as an option.
Method _could_set_option Check whether a command line arg could set the given option.
Method _describe_why_argparse_wont_read_arg_as_a_value Says why argparse may not read the given command line arg as a value.
Method _fill_in_action_attributes_this_module_reads Give each action the attributes this module's add_argument() sets.
Method _find_end_of_this_parsers_args Find where the args this parser parses itself end.
Method _find_insertion_index Find the right index to insert config/env var args into the command line.
Method _find_option_that_takes_its_values_from_later_args Find the option an arg names, if its values are the args after it.
Method _find_subcommand_index Find where the subcommand is on the command line, if there is one.
Method _find_where_args_stop_being_read_as_options Find where argparse stops reading this parser's args as options.
Method _get_args_that_set_boolean_optional_action Picks the option string that sets a BooleanOptionalAction arg to the value given for it in a config file or env var.
Method _get_value Convert a string to a value for an action, as argparse does, and record the string the value came from.
Method _get_values Convert an action's args to its value, as argparse does, and record whether it was given any.
Method _has_a_remainder_positional Check whether this parser has a positional arg with nargs=REMAINDER.
Method _indexes_of_positional_args Find the args argparse reads as positional args.
Method _insert_args_from_config_file_or_env_vars Insert the args that one config file or the env vars set.
Method _names_a_write_out_config_file_arg Check whether a command line arg would set a write-out-config-file arg.
Method _open_config_files Tries to parse config file path(s) from within command_line_args. Returns a list of opened config files, including files specified on the commandline as well as any default_config_files specified in the constructor that are present on disk.
Method _option_strings_that_override Find the option strings that, when already on the command line, mean an env var or config file value for the given action should be dropped.
Method _reject_unrecognized_args Report args that no arg of this parser took, the way argparse does.
Method _replace_parsed_values_with_the_strings_they_came_from Put back the string a value came from where str() can't stand in for it.
Method _report_error Report an error the way argparse does for its own errors.
Method _synthesized_args_dont_set_a_write_out_config_file_arg Reject synthesized command line args that set a write-out-config-file arg.
Method _write_out_config_file_args Find the write-out-config-file args the given parsers define.
Instance Variable _actions_given_values Undocumented
Instance Variable _add_config_file_help Undocumented
Instance Variable _add_env_var_help Undocumented
Instance Variable _argparse_is_parsing_intermixed_args Undocumented
Instance Variable _auto_env_var_prefix Undocumented
Instance Variable _config_file_open_func Undocumented
Instance Variable _config_file_parser Undocumented
Instance Variable _default_config_files Undocumented
Instance Variable _ignore_unknown_config_file_keys Undocumented
Instance Variable _parsed_values_and_the_strings_they_came_from Undocumented
Instance Variable _parsing_intermixed_args Undocumented
Instance Variable _source_to_settings Undocumented
Instance Variable _write_out_config_file_paths Undocumented

Inherited from ArgumentParser:

Method add_subparsers Undocumented
Method convert_arg_line_to_args Undocumented
Method error error(message: string)
Method exit Undocumented
Method format_usage Undocumented
Method print_help Undocumented
Method print_usage Undocumented
Instance Variable add_help Undocumented
Instance Variable allow_abbrev Undocumented
Instance Variable epilog Undocumented
Instance Variable formatter_class Undocumented
Instance Variable fromfile_prefix_chars Undocumented
Instance Variable prog Undocumented
Instance Variable usage Undocumented
Method _add_action Undocumented
Method _check_value Undocumented
Method _get_formatter Undocumented
Method _get_kwargs Undocumented
Method _get_nargs_pattern Undocumented
Method _get_option_tuples Undocumented
Method _get_optional_actions Undocumented
Method _get_positional_actions Undocumented
Method _match_argument Undocumented
Method _match_arguments_partial Undocumented
Method _parse_known_args Undocumented
Method _parse_optional Undocumented
Method _print_message Undocumented
Method _read_args_from_files Undocumented
Instance Variable _optionals Undocumented
Instance Variable _positionals Undocumented
Instance Variable _subparsers Undocumented

Inherited from _AttributeHolder (via ArgumentParser):

Method __repr__ Undocumented
Method _get_args Undocumented

Inherited from _ActionsContainer (via ArgumentParser, _AttributeHolder):

Method add_argument add_argument(dest, ..., name=value, ...) add_argument(option_string, option_string, ..., name=value, ...)
Method add_argument_group Undocumented
Method add_mutually_exclusive_group Undocumented
Method get_default Undocumented
Method register Undocumented
Method set_defaults Undocumented
Instance Variable argument_default Undocumented
Instance Variable conflict_handler Undocumented
Instance Variable description Undocumented
Instance Variable prefix_chars Undocumented
Method _add_container_actions Undocumented
Method _check_conflict Undocumented
Method _get_handler Undocumented
Method _get_optional_kwargs Undocumented
Method _get_positional_kwargs Undocumented
Method _handle_conflict_error Undocumented
Method _handle_conflict_resolve Undocumented
Method _pop_action_class Undocumented
Method _registry_get Undocumented
Method _remove_action Undocumented
Instance Variable _action_groups Undocumented
Instance Variable _actions Undocumented
Instance Variable _defaults Undocumented
Instance Variable _has_negative_number_optionals Undocumented
Instance Variable _mutually_exclusive_groups Undocumented
Instance Variable _negative_number_matcher Undocumented
Instance Variable _option_string_actions Undocumented
Instance Variable _registries Undocumented
def __init__(self, *args, **kwargs): (source)

Supports args of the argparse.ArgumentParser constructor as **kwargs, as well as the following additional args.

Parameters
*argsUndocumented
add_config_file_helpWhether to add a description of config file syntax to the help message.
add_env_var_helpWhether to add something to the help message for args that can be set through environment variables.
auto_env_var_prefixIf set to a string instead of None, all config- file-settable options will become also settable via environment variables whose names are this prefix followed by the config file key, all in upper case. (eg. setting this to foo_ will allow an arg like --my-arg to also be set via the FOO_MY_ARG environment variable)
default_config_files

When specified, this list of config files will be parsed in order, with the values from each config file taking precedence over previous ones. This allows an application to look for config files in multiple standard locations such as the install directory, home directory, and/or current directory. Also, shell * syntax can be used to specify all conf files in a directory, which are then parsed in alphabetical order. For example:

["/etc/conf/app_config.ini",
"/etc/conf/conf-enabled/*.ini",
"~/.my_app_config.ini",
"./app_config.txt"]

Path entries may be strings, os.PathLike objects (e.g. pathlib.Path), or zero-argument callable functions that return an open file-like object containing config file contents. Any provided callable is invoked each time the parser opens config files, and the returned stream is closed by the parser after parsing. The callable must return a stream. This is useful for sourcing config from non-filesystem locations such as in-memory buffers, secrets managers, or HTTP responses.

ignore_unknown_config_file_keysIf true, settings that are found in a config file but don't correspond to any defined configargparse args will be ignored. If false, they will be processed and appended to the commandline like other args, and can be retrieved using parse_known_args() instead of parse_args()
config_file_open_funcfunction used to open a config file for reading or writing. Needs to return a file-like object.
config_file_parser_classa configargparse.ConfigFileParser subclass, or an instance of one, which determines the config file format. configargparse comes with DefaultConfigFileParser, YAMLConfigFileParser, ConfigparserConfigFileParser, IniConfigParser, TomlConfigParser and CompositeConfigParser. The last three take constructor args, so pass them as instances, eg. TomlConfigParser(['tool.my_tool']).
args_for_setting_config_pathA list of one or more command line args to be used for specifying the config file path (eg. ["-c", "--config-file"]). Default: []
config_arg_is_requiredWhen args_for_setting_config_path is set, set this to True to always require users to provide a config path.
config_arg_help_messagethe help message to use for the args listed in args_for_setting_config_path.
args_for_writing_out_config_fileA list of one or more command line args to use for specifying a config file output path. If provided, these args cause configargparse to write out a config file with settings based on the other provided commandline args, environment variants and defaults, and then to exit. (eg. ["-w", "--write-out-config-file"]). Default: [] These args can only be set on the command line. A config file key that names one is an error, and they can't have an env_var, since either would let whoever controls those overwrite an arbitrary file.
write_out_config_file_arg_help_messageThe help message to use for the args in args_for_writing_out_config_file.
def convert_item_to_command_line_arg(self, action, key, value): (source)

Converts a config file or env var key + value to a list of commandline args to append to the commandline.

Parameters
actionThe argparse Action object for this setting, or None if this config file setting doesn't correspond to any defined configargparse arg.
keystring (config file key or env var name)
valueparsed value of type string or list
Returns
list[str]args
def format_help(self, formatter=None): (source)

Undocumented

def format_values(self): (source)

Returns a string with all args and settings and where they came from (eg. commandline, config file, environment variable or default)

Returns
strsource to settings string
def get_command_line_key_for_unknown_config_file_setting(self, key): (source)

Compute a commandline arg key to be used for a config file setting that doesn't correspond to any defined configargparse arg (and so doesn't have a user-specified commandline arg key).

Parameters
keyThe config file key that was being set.
Returns
strcommand line key
def get_items_for_config_file_output(self, source_to_settings, parsed_namespace): (source)

Converts the given settings back to a dictionary that can be passed to ConfigFileParser.serialize(..).

Parameters
source_to_settingsthe dictionary returned by get_source_to_settings_dict()
parsed_namespacenamespace object created within parse_known_args()
Returns
OrderedDictwhere keys are strings and values are a str, int, float or bool, or a list whose elements are any of these or lists of them
def get_possible_config_keys(self, action): (source)

This method decides which actions can be set in a config file and what their keys will be. It returns a list of 0 or more config keys that can be used to set the given action's value in a config file.

Returns
list[str]keys
def get_source_to_settings_dict(self): (source)

If called after parse_args() or parse_known_args(), returns a dict whose keys say where values came from, each mapped to a dict of the settings from there:

  • "command_line": maps "" to (None, the list of command line args).
  • "environment_variables": maps each env var name to (argparse.Action obj, the env var's value).
  • "config_file|<source>": one key per config file that set anything, eg. "config_file|/etc/app.conf", or "config_file|method arg" for config_file_contents passed to parse_args(). Maps each config file key to (argparse.Action obj, or None for a key that no arg has, the value as read, a str or a list).
  • "defaults": maps each arg's last option string (or dest, for a positional arg) to (argparse.Action obj, str() of its default).
Returns
dict[str, dict[str, tuple]]source to settings dict
def parse_args(self, args=None, namespace=None, config_file_contents=None, env_vars=os.environ): (source)

Supports all the same args as the argparse.ArgumentParser.parse_args(), as well as the following additional args.

Parameters
argsa list of args as in argparse, or a string (eg. "-x -y bla")
namespaceUndocumented
config_file_contentsString. Used for testing.
env_varsDictionary. Used for testing.
Returns
argparse.Namespacenamespace
def parse_intermixed_args(self, args=None, namespace=None, config_file_contents=None, env_vars=os.environ): (source)

Like parse_args(), but lets optional and positional args be intermixed, as argparse.ArgumentParser.parse_intermixed_args() does.

Parameters
argsa list of args as in argparse, or a string (eg. "-x -y bla")
namespaceUndocumented
config_file_contentsString. Used for testing.
env_varsDictionary. Used for testing.
Returns
argparse.Namespacenamespace
def parse_known_args(self, args=None, namespace=None, config_file_contents=None, env_vars=os.environ, ignore_help_args=False): (source)

Supports all the same args as the argparse.ArgumentParser.parse_args(), as well as the following additional args.

Parameters
argsa list of args as in argparse, or a string (eg. "-x -y bla")
namespaceUndocumented
config_file_contents:str
env_vars:dict
ignore_help_args:boolThis flag determines behavior when user specifies --help or -h. If False, it will have the default behavior - printing help and exiting. If True, it won't do either.
Returns
tuple[argparse.Namespace, list[str]]tuple namescpace, unknown_args
def parse_known_intermixed_args(self, args=None, namespace=None, config_file_contents=None, env_vars=os.environ, ignore_help_args=False): (source)

Like parse_known_args(), but lets optional and positional args be intermixed, as argparse.ArgumentParser.parse_known_intermixed_args() does.

Parameters
argsa list of args as in argparse, or a string (eg. "-x -y bla")
namespaceUndocumented
config_file_contents:str
env_vars:dict
ignore_help_args:boolsee parse_known_args().
Returns
tuple[argparse.Namespace, list[str]]tuple namespace, unknown_args
def print_values(self, file=None): (source)

Prints the format_values() string (to sys.stdout or another file).

def write_config_file(self, parsed_namespace, output_file_paths, exit_after=False): (source)

Write the given settings to output files.

Parameters
parsed_namespacenamespace object created within parse_known_args()
output_file_pathsany number of file paths to write the config to
exit_afterwhether to exit the program after writing the config files
exit_on_error: bool = (source)

Undocumented

def _add_args_from_source(self, args, actions_keys_and_values, source_description, variable_length_list_ends, flag_actions_set_by_higher_priority_sources): (source)

Turn the settings from one config file or the env vars into args.

Parameters
argsthe command line args so far.
actions_keys_and_values(action, key, value) for each setting from the source that isn't set by a higher-priority source. action is None for a config file key that no arg has.
source_descriptionwhere the settings came from, for error messages, eg. "in an environment variable".
variable_length_list_endssee _insert_args_from_config_file_or_env_vars(), updated in place.
flag_actions_set_by_higher_priority_sourcesthe flag actions set by sources that take precedence over the ones still to come, updated in place with this source's flags.
Returns
tuplethe new command line args, and whether this source's args were added to them (they aren't when one would set a write-out-config-file arg)
def _arg_is_an_option_that_takes_every_later_arg(self, arg_string): (source)

Check whether an arg names an option with nargs=REMAINDER.

Such an option takes every arg after it as its values, options included.

Parameters
arg_stringa single command line arg.
Returns
boolwhether it names one
def _arg_is_read_as_an_option(self, arg_string): (source)

Check whether argparse reads a command line arg as an option.

A lone prefix char (eg. '-' for stdin) is a value, and so is a negative number when the parser has no option that looks like one. This uses argparse's own pattern for a negative number, which differs by Python version (from 3.14 it also matches eg. "-1e5").

Parameters
arg_stringa single command line arg.
Returns
boolwhether it is an option (or the '--' separator) rather than a value
def _could_set_option(self, arg_string, option_string): (source)

Check whether a command line arg could set the given option.

This covers every form argparse accepts: the option on its own, with its value attached after an = (or, for a short option, straight after it), bundled with other short options, and abbreviated. Where argparse would need to look at the rest of the command line to decide, this says yes, since it is used to reject args that must not reach an option at all, and being wrong in that direction only costs an error message.

Parameters
arg_stringa single command line arg.
option_stringan option string of the option to look for.
Returns
boolwhether the arg could set the option
def _describe_why_argparse_wont_read_arg_as_a_value(self, arg): (source)

Says why argparse may not read the given command line arg as a value.

This is stricter than argparse, which also reads some other args that start with a prefix char as values, such as one that contains a space.

Parameters
arg:stra command line arg.
Returns
strwhat's wrong with it, worded to follow "<key> can't have", or None if argparse reads it as a value.
def _fill_in_action_attributes_this_module_reads(self): (source)

Give each action the attributes this module's add_argument() sets.

An action that didn't go through it, eg. one copied from a plain argparse parser passed as parents=, gets them with their default values, so the code that reads them works the same for every action. With auto_env_var_prefix set, each action that can have an env var and has none gets its automatic one. Both parsing and the help text read these, so this runs before either.

def _find_end_of_this_parsers_args(self, args): (source)

Find where the args this parser parses itself end.

Parameters
argsthe command line args.
Returns
int or Nonethe index of the subcommand, or else of where argparse stops reading args as options (see _find_where_args_stop_being_read_as_options()), or None
def _find_insertion_index(self, args): (source)

Find the right index to insert config/env var args into the command line.

Inserts at position 0 when a REMAINDER positional exists, otherwise before a subparser command (one before any --) so the parent parser sees injected args first, otherwise before an option with nargs=REMAINDER or the -- separator if present, or before the first optional arg. Falls back to appending.

def _find_option_that_takes_its_values_from_later_args(self, arg_string): (source)

Find the option an arg names, if its values are the args after it.

Parameters
arg_stringa single command line arg that is read as an option.
Returns
argparse.Action or Nonethe option named exactly, or by an unambiguous abbreviation of a long option, or None if the arg names none or has its value attached with '='
def _find_subcommand_index(self, args): (source)

Find where the subcommand is on the command line, if there is one.

An arg that is the value of the option before it, like the first 'build' in '--target build build', isn't the subcommand, so the values of an option named exactly, and taking a set number of them, are skipped the way argparse reads them.

Parameters
argsthe command line args.
Returns
int or Nonethe index of the first arg naming a subcommand
def _find_where_args_stop_being_read_as_options(self, args): (source)

Find where argparse stops reading this parser's args as options.

That is at the '--' separator, with a REMAINDER positional at its first arg, or just after an option with nargs=REMAINDER that comes before any subcommand, since those take every arg from there on, options included.

Parameters
argsthe command line args.
Returns
int or Nonethat index, or None if argparse reads them all
def _get_args_that_set_boolean_optional_action(self, action, key, value): (source)

Picks the option string that sets a BooleanOptionalAction arg to the value given for it in a config file or env var.

argparse adds a negative form after some option strings of a BooleanOptionalAction ('--no-foo' after '--foo', and from Python 3.15 also '++no-foo' after '++foo' and '-nofoo' after '-foo'), and sets the arg to False for the negative forms and to True for the rest. A short alias can come first, so the negative forms aren't at a fixed position. A config file key that names a negative form (eg. 'no-feature' for '--no-feature') means the opposite value, so 'no-feature = true' sets the arg to False, just as '--no-feature' would on the command line.

Parameters
actionThe argparse.BooleanOptionalAction to set.
keyThe config file key or env var name the value came from.
valueThe boolean value given for that key.
Returns
listthe option string to add to the command line, or no args if none of the option strings sets that value
def _get_value(self, action, arg_string): (source)

Convert a string to a value for an action, as argparse does, and record the string the value came from.

argparse converts each command line or env var string this way, and a string default or const too. A type= callable can make a value whose str() it can't read back, such as a dict from json.loads or the open file argparse.FileType makes, so a config file written out for that value holds the recorded string instead (see _replace_parsed_values_with_the_strings_they_came_from()).

Parameters
actionthe action the string is for.
arg_stringthe string.
Returns
objectthe value argparse made from it
def _get_values(self, action, arg_strings): (source)

Convert an action's args to its value, as argparse does, and record whether it was given any.

Parameters
actionthe action the args are for.
arg_stringsthe args argparse took for it.
Returns
objectthe value argparse made from them
def _has_a_remainder_positional(self): (source)

Check whether this parser has a positional arg with nargs=REMAINDER.

Returns
boolwhether it has one
def _indexes_of_positional_args(self, args): (source)

Find the args argparse reads as positional args.

Options aren't, and neither are an option's values, which are skipped the way argparse reads them: nargs=None or '?' takes the next arg, an int n takes up to n, and '*' or '+' take every arg up to the next option, as long as they aren't options themselves. A value attached with '=' takes nothing more, and an option with nargs=REMAINDER takes everything after it.

Parameters
argsthe command line args.
Yields
intthe index of each positional arg, in order
def _insert_args_from_config_file_or_env_vars(self, args, variable_length_list_args, other_args, last_variable_length_list_key, variable_length_list_ends): (source)

Insert the args that one config file or the env vars set.

argparse reads every arg after the values of an option that takes any number of values as one more value, until the next option. So those lists go first, where the source's other args end them. When nothing from the source follows them and the command line goes on with a subcommand or positional, they go before the first option on the command line instead, if there is one. Where a block that ends with such a list ends is recorded, so that parse_known_args() can check what follows it once every source is in. When an earlier source's list is still followed by a subcommand or positional, this source's args go where that list ends, which ends it.

Parameters
argsthe command line args so far.
variable_length_list_argsthe args that set options taking any number of values to a list.
other_argsthe source's other args.
last_variable_length_list_keythe config file key or env var that set the last of those lists, for an error message.
variable_length_list_ends(index, key) pairs, updated in place.
Returns
listthe args with these inserted
def _names_a_write_out_config_file_arg(self, arg_string, parsers): (source)

Check whether a command line arg would set a write-out-config-file arg.

Parameters
arg_stringa single command line arg.
parsersthe parsers that could end up parsing it.
Returns
boolwhether it names a write-out-config-file arg
def _open_config_files(self, command_line_args): (source)

Tries to parse config file path(s) from within command_line_args. Returns a list of opened config files, including files specified on the commandline as well as any default_config_files specified in the constructor that are present on disk.

Parameters
command_line_argsList of all args
Returns
list[tuple[io.IOBase, str]]list of (stream, source_label) pairs. The source_label is unique per entry (file path for path entries; "<entry_label>[<index>]" for callable entries), so different entries cannot collapse into a single source key in format_values().
def _option_strings_that_override(self, action): (source)

Find the option strings that, when already on the command line, mean an env var or config file value for the given action should be dropped.

These are the action's own option strings plus those of every other action in the same mutually exclusive group, mirroring the conflicts argparse checks for. Without the latter, a config file value for one member of a group would clash with a different member given on the command line instead of being overridden by it (see issue #164).

Parameters
actionthe argparse.Action to find overriding option strings for.
Returns
list[str]the option strings
def _reject_unrecognized_args(self, unrecognized_args): (source)

Report args that no arg of this parser took, the way argparse does.

Parameters
unrecognized_argsthe args left over after parsing.
def _replace_parsed_values_with_the_strings_they_came_from(self, action, value): (source)

Put back the string a value came from where str() can't stand in for it.

Only a value other than a str, int, float, bool or Enum (eg. a dict from type=json.loads, or a list from a type= callable that splits its string) is replaced, and only when it is the very object argparse made for this action from a string in the last parse: a command line or env var value, or a string default or const. So a value set any other way, such as a default that isn't a string, is kept.

Parameters
actionthe action the value was parsed for.
valuea parsed arg value, or an element of a list value.
Returns
objectthe value, with each such value or list element replaced
def _report_error(self, message): (source)

Report an error the way argparse does for its own errors.

With exit_on_error=False, argparse raises an ArgumentError instead of exiting, so errors in config files and env vars do the same.

Parameters
messagethe error message.
def _synthesized_args_dont_set_a_write_out_config_file_arg(self, synthesized_args, source_description, parsers): (source)

Reject synthesized command line args that set a write-out-config-file arg.

Config file entries and environment variables are turned into command line args and then parsed like any others, so either one's key or its value can end up naming an arg. A write-out-config-file arg overwrites the path it is given and then exits the program, so only the real command line may set one: otherwise whoever controls a config file the program reads could destroy an arbitrary file without the user passing any args at all. (This is also why get_possible_config_keys() keeps these args out of the keys a config file can set.)

These args are checked against every parser reachable from this one, not just the one that looks like it will parse them. Which subcommand runs can't be told from the args: an option's value reads exactly like a subcommand name, and the synthesized args can name a subcommand themselves. So a config file may not name a write-out arg anywhere in the parser tree, which costs an error on a key named after one on a subcommand that wasn't going to run.

Parameters
synthesized_argscommand line args built from a config file or from environment variables, before they are added to the real ones.
source_descriptionwhere they came from, for the error message.
parsersthe parsers that could end up parsing them: this parser and every subparser reachable from it (see _subparsers_of()). A subparser is given the args this parser has put together and treats them as its own command line, and argparse parses it into this parser's namespace, so both what a subparser accepts and what it stores matter here. Subparsers that aren't ConfigArgParse parsers are walked through as well, since one of them can hold a subparser that is.
Returns
boolwhether the args may be used. error() is meant to stop the program, but a program can override exit(), so this says so rather than counting on the call not returning.
def _write_out_config_file_args(self, parsers): (source)

Find the write-out-config-file args the given parsers define.

Parameters
parsersthe parsers to look in.
Returns
listeach such arg as an (argparse.ArgumentParser, argparse.Action) pair, since it's the parser an arg belongs to that decides which command line args can set it.
_actions_given_values: set = (source)

Undocumented

_add_config_file_help = (source)

Undocumented

_add_env_var_help = (source)

Undocumented

_argparse_is_parsing_intermixed_args: bool = (source)

Undocumented

_auto_env_var_prefix = (source)

Undocumented

_config_file_open_func = (source)

Undocumented

_config_file_parser = (source)

Undocumented

_default_config_files = (source)

Undocumented

_ignore_unknown_config_file_keys = (source)

Undocumented

_parsed_values_and_the_strings_they_came_from: list = (source)

Undocumented

_parsing_intermixed_args: bool = (source)

Undocumented

_source_to_settings = (source)

Undocumented

_write_out_config_file_paths = (source)

Undocumented