bw2 / ConfigArgParse

A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Config files render various errors in combination with default values

ftrofin opened this issue · comments

This is related to #245 I think.
I'm seeing the same error when I specify a config file. In my case I have a boolean flag that has a default value:

parser_create.add_argument('-r', '--recurse', action=argparse.BooleanOptionalAction, default=True,

I'm also using subcommands (parser_create above was created by parser_create = subparsers.add_parser('create')) and they don't work well at all with ConfigArgParse.
I've tried both config file formats, I get different errors with each of them. Interop with the config files was what made ConfigArgParse attractive but it seems that this doesn't really work in more real-world scenarios. I'd be happy to provide more details if you need them.

@ftrofin maybe you might want to try out jsonargparse. It is very actively maintained and has many more features that you might find useful. A thing to note is that subcommands work a bit different that in argparse, see the docs.