When using dependency_provider.dependency_overrides, the override seems to overwrite the function in the dependency, but still passes the new function the resolved dependencies of the old function. I would expect the old functions dependencies to be ignored in the overridden context.
from fast_depends import Depends, dependency_provider, inject
def get_parent_dep():
return 1
def get_dep(parent_dep=Depends(get_parent_dep)):
return parent_dep + 1
@inject
def my_func(dep=Depends(get_dep)):
print(dep + 1)
my_func() # Normal, as expected
dependency_provider.dependency_overrides[get_dep] = lambda: 100
my_func() # Error as my override lambda is being passed a dependency from the old get_dep function
(.venv) $ python test.py
3
Traceback (most recent call last):
File "main.py", line 21, in <module>
my_func()
File "/.venv/lib/python3.9/site-packages/fast_depends/use.py", line 169, in injected_wrapper
r = real_model.solve(
File ".venv/lib/python3.9/site-packages/fast_depends/core/model.py", line 370, in solve
dep.solve(
File ".venv/lib/python3.9/site-packages/fast_depends/core/model.py", line 416, in solve
response = call(*final_args, **final_kwargs)
TypeError: <lambda>() got an unexpected keyword argument 'parent_dep'
When using
dependency_provider.dependency_overrides
, the override seems to overwrite the function in the dependency, but still passes the new function the resolved dependencies of the old function. I would expect the old functions dependencies to be ignored in the overridden context.Using version
2.4.11