From fb0e977074c21410eeaa82feafcbc165d9e0b0a0 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 4 Mar 2022 20:18:00 +0000 Subject: [PATCH] Allow config args to be not first --- configargparse.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configargparse.py b/configargparse.py index b447396e..1ef00af0 100644 --- a/configargparse.py +++ b/configargparse.py @@ -889,6 +889,8 @@ def _open_config_files(self, command_line_args): if not user_config_file_arg_actions: return config_files + positional_args = [a for a in self._actions if getattr(a, "is_positional_arg", False)] + for action in user_config_file_arg_actions: # try to parse out the config file path by using a clean new # ArgumentParser that only knows this one arg/action. @@ -896,6 +898,7 @@ def _open_config_files(self, command_line_args): prefix_chars=self.prefix_chars, add_help=False) + [arg_parser._add_action(a) for a in positional_args] arg_parser._add_action(action) # make parser not exit on error by replacing its error method.