You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perhaps an odd situation, but if I use positional arguments AND my config file is not the first argument, the file is not opened. For example:
main.py
import configargparse
p = configargparse.get_argument_parser()
p.add_argument("first_argument")
p.add_argument("config", is_config_file=True)
p.add_argument("--option")
arguments = p.parse_known_args() # or parse_args()
print(arguments)
config.ini
option = yes
And execute it with
python main.py first config.ini:
usage: mwe-fails.py [-h] [--option OPTION] first_argument config
mwe-fails.py: error: Unable to open config file: first. Error: No such file or directory
However, if I switch the order of arguments and modify the command appropriately, I get the expected behavior
The text was updated successfully, but these errors were encountered:
It does seem an unusual use case, but I had a look at whether this part of the code could be made more elegant. I propose that, rather than creating subordinate argparse objects in a loop to detect config file settings, a single subordinate parser is created. I coded this up and it seems more elegant to me, and has other benefits including fixing this issue.
Perhaps an odd situation, but if I use positional arguments AND my config file is not the first argument, the file is not opened. For example:
main.py
config.ini
And execute it with
python main.py first config.ini
:However, if I switch the order of arguments and modify the command appropriately, I get the expected behavior
The text was updated successfully, but these errors were encountered: