Add *args and **kwargs to _parse_known_args, and pass them through to the call to super(). _parse_known_args

This commit is contained in:
JamesParrott 2024-11-17 12:09:51 +00:00 committed by Gil Forsyth
parent f2e4c93785
commit 58ca7e77b7

View file

@ -354,7 +354,9 @@ class ArgParser(ap.ArgumentParser):
add_args(parser, func, allowed_params=args, doc=doc)
return parser
def _parse_known_args(self, arg_strings: list[str], namespace: ap.Namespace):
def _parse_known_args(
self, arg_strings: list[str], namespace: ap.Namespace, *args, **kwargs
):
arg_set = set(arg_strings)
if (
self.commands
@ -363,7 +365,7 @@ class ArgParser(ap.ArgumentParser):
and (set(self.commands.choices).isdisjoint(arg_set))
):
arg_strings = [self.default_command] + arg_strings
return super()._parse_known_args(arg_strings, namespace)
return super()._parse_known_args(arg_strings, namespace, *args, **kwargs)
def run_with_partial_args(func: tp.Callable, ns: dict[str, tp.Any]):