Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with argparse.BooleanOptionalAction #245

Closed
ftesser opened this issue Aug 17, 2021 · 3 comments
Closed

Issue with argparse.BooleanOptionalAction #245

ftesser opened this issue Aug 17, 2021 · 3 comments

Comments

@ftesser
Copy link
Contributor

ftesser commented Aug 17, 2021

Following #239, I just tested the new release (ConfigArgParse 1.5.2), using the same code reported in #239: now there is not the error reported in #239 (thanks!), but the functionality is not as I expected.

The issues are:

  1. when I try to save the config file without any indication about foo, the default False is not taken into consideration and the config.conf is empty:
$ python boolean_optional_action_test.py --generate_config_file config.conf
Wrote config file to config.conf
$ cat config.conf
  1. Setting the --foo in the command line:
$ python boolean_optional_action_test.py --generate_config_file config.conf --foo
Wrote config file to config.conf
$ cat config.conf
foo = true

the config file correctly contains some info about foo (true), but this is not readable from the parser, in fact parsing this config file return the default foo = False and not the True value contained in the file:

python boolean_optional_action_test.py --config_file config.conf
Namespace(config_file='config.conf', write_out_config_file_to_this_path=None, foo=False)

Any idea of how to manage that?

@bw2
Copy link
Owner

bw2 commented Aug 27, 2021

Sorry about the remaining issue(s). I'm not sure when I'll be able to work on this. In the mean time, a PR to fix it would be appreciated.

@ftesser
Copy link
Contributor Author

ftesser commented Sep 10, 2021

Hello @bw2, I have just sent a PR that fix the second part of this issue (the reading from config file).

The problem that the default arguments are not saved in the config file is still there, but for this problem it might be better to open a separate issue, because I see that this problem is not related only to action=BooleanOptionalAction but also to action = " store_true ". I think that perhaps the _writing_out_config_file function was designed like that (do not save the default arguments).

@ftesser
Copy link
Contributor Author

ftesser commented Oct 1, 2021

Close the issue after merging #248

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants