Skip to content

Conversation

Zhenay
Copy link
Contributor

@Zhenay Zhenay commented May 22, 2025

Inject did not work properly when you made a dependency on already injected generator function (both sync and async)

from fast_depends import Depends, inject

@inject
def dep():
    yield 5

@inject
def func1(a = Depends(dep)):
    print(a)

# print "<fast_depends.use.solve_gen object at 0x...>"

@inject
def func2(a: int = Depends(dep)):
    print(a)

# raise ValidationError:
# ...
# ValidationError: 1 validation error for func2
# a
#   Input should be a valid integer [type=int_type, input_value=<fast_depends.use.solve_g...bject at 0x...>, input_type=solve_gen]
# ...

@Lancetnik Lancetnik merged commit acdfb6b into Lancetnik:main May 22, 2025
15 checks passed
Lancetnik added a commit that referenced this pull request Aug 12, 2025
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