Skip to content

Commit

Permalink
chore: #112 pr
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik committed Sep 5, 2024
1 parent 21c2f61 commit 0c1ec53
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
14 changes: 7 additions & 7 deletions fast_depends/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ def _solve(
keyword_args = self.keyword_args

else:
keyword_args = set(self.keyword_args + self.positional_args)
for arg in keyword_args - set(self.dependencies.keys()):
if arg not in kw:
if args:
kw[arg], args = args[0], args[1:]
else:
break
keyword_args = self.keyword_args + self.positional_args
for arg in keyword_args:
if not args:
break

if arg not in self.dependencies and arg not in kw:
kw[arg], args = args[0], args[1:]

solved_kw: Dict[str, Any]
solved_kw = yield args, kw
Expand Down
17 changes: 17 additions & 0 deletions tests/library/test_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ def sync_catch2(key2: HeaderKey) -> float:
assert sync_catch2(headers={"key2": 1}) == 1


def test_arguments_mapping():
@inject
def func(
d: int = CustomField(cast=False),
b: int = CustomField(cast=False),
c: int = CustomField(cast=False),
a: int = CustomField(cast=False),
):
assert d == 4
assert b == 2
assert c == 3
assert a == 1

for _ in range(50):
func(4, 2, 3, 1)


@serializer
class TestSerializer:
@pytest.mark.anyio
Expand Down

0 comments on commit 0c1ec53

Please sign in to comment.