Skip to content

Commit

Permalink
provider parameters were being removed bc not in signature (#6348)
Browse files Browse the repository at this point in the history
Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
  • Loading branch information
hjoaquim and IgorWounds authored Apr 29, 2024
1 parent efe77be commit a502766
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def __init__(
self.func = func
self.signature = inspect.signature(func)
self.type_hints = get_type_hints(func)
self.provider_parameters = []

self._parser = argparse.ArgumentParser(
prog=func.__name__,
Expand All @@ -221,6 +222,7 @@ def __init__(
# If the argument is already in use, we can't repeat it
if f"--{argument.name}" not in self._parser_arguments():
argparse_group.add_argument(f"--{argument.name}", **kwargs)
self.provider_parameters.append(argument.name)

def _parser_arguments(self) -> List[str]:
"""Get all the arguments from all groups currently defined on the parser."""
Expand Down Expand Up @@ -495,11 +497,11 @@ def execute_func(
kwargs = self._unflatten_args(vars(parsed_args))
kwargs = self._update_with_custom_types(kwargs)

# remove kwargs that doesn't match the signature
# remove kwargs that doesn't match the signature or provider parameters
kwargs = {
key: value
for key, value in kwargs.items()
if key in self.signature.parameters
if key in self.signature.parameters or key in self.provider_parameters
}

return self.func(**kwargs)
Expand Down

0 comments on commit a502766

Please sign in to comment.