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

fix: improve error message on failed injection #37

Merged
merged 2 commits into from
Aug 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/in_n_out/_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,12 +767,13 @@ def _exec(*args: P.args, **kwargs: P.kwargs) -> R:
# if desired. (i.e. the injected deps are only used if not provided)
bound = _sig.bind_partial(*args, **kwargs)
bound.apply_defaults()
_kwargs.update(**bound.arguments)

# call the function with injected values
try:
result = func(**_kwargs)
result = func(**{**_kwargs, **bound.arguments})
except TypeError as e:
if "missing" not in e.args[0]:
raise # pragma: no cover
# likely a required argument is still missing.
# show what was injected and raise
_argnames = (
Expand Down