ConfigArgParse
ConfigArgParse copied to clipboard
Boolean options in higher priority configs ignored
main.py
:
parser = configargparse.get_argument_parser(default_config_files=['default.cfg', 'user.cfg'])
parser.add('--key', action='store_true')
args = parser.parse_args()
default.cfg
:
key: True
user.cfg
:
key: False
args.key
will be True
This is because, config files are processed in descending priority, and when using store_true
in the config files, key = False
is ignored rather than considered already_on_command_line
.
If you can submit a PR, it would be much appreciated.
I threw in handling for boolean and list values early on (https://github.com/bw2/ConfigArgParse#special-values), in a way that handles simple cases but doesn't generalize. It would be great if someone could take on refactoring this.
It would be super useful if "someone" could fix this. We use ConfigArgParse in locust (https://github.com/locustio/locust/).
Sorry for the "me too"-type post, but I just wanted to let you know how much we appreciate this library and how awesome it would be if this tiny thing were to be fixed :)