Skip to content

Commit

Permalink
Ensure that passed kwargs actually are the same as the parameter name…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
rspnijones committed Oct 7, 2024
1 parent d328551 commit 8e12738
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kink/inject.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _resolve_kwargs(args, kwargs) -> dict:
passed_kwargs[parameters_name[key]] = value

# prioritise passed kwargs and args resolving
if len(passed_kwargs) == len(parameters_name):
if set(passed_kwargs.keys()) == set(parameters_name):
return passed_kwargs

resolved_kwargs = _resolve_function_kwargs(binding, parameters_name, parameters, container)
Expand Down

0 comments on commit 8e12738

Please sign in to comment.