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

Bugfix: @inject was not resolving all arguments when used with kwargs #66

Merged
merged 1 commit into from
Oct 19, 2024

Conversation

rspnijones
Copy link
Contributor

We ran into a scenario where the inject failed, with this function signature:

@Inject
def _function(self,filename, perforce=None, **kwargs): #perforce is a registered with kink

and callsite:

self._function(filename, exportRoots=top_node, stripNamespaces=True)

The test if len(passed_kwargs) == len(parameters_name):

Returns true and bypasses resolving the services without actually testing if the supplied kwargs are the kwargs in the function.

Our bugfix updates that line to ensure the names agree so that we don't bypass the resolver sometimes.

…s instead of compare lengths to avoid false positives when mixing @Inject with **kwargs

Before it would just check the length of passed arguments vs the signature but that breaks down with **kwarg usage as you can hit cases where the number of passed arguments makes up for the arguments expected to be resolved by inject and then the resolve step is bypassed - leading to exceptions later.
@dkraczkowski dkraczkowski merged commit f605a30 into kodemore:master Oct 19, 2024
6 checks passed
@dkraczkowski
Copy link
Contributor

@rspnijones Thanks for your contribution.

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

Successfully merging this pull request may close these issues.

2 participants