that-depends
that-depends copied to clipboard
Allow dependency providers with arguments.
Common difficulty which currently requires some kind of "work-around"
@app.get("/")
async def endpont(r: Request, value = fastapi.Depends(Container.provider)):
...
Where the provider is actually a dependent of the Request
def get_dependency_based_on_request(r: Request) :
...
class Container(BaseContainer):
provider = providers.SomeProvider(get_dependency_based_on_request)
Feature request
- Allow providers to accept arguments during resolution, i.e. when calling
provider.resolve()orproviders.resolve_sync() - Allow to pass function arguments to injected dependencies (similar to
fastapi.Depends())
Will for now only implement for Factory providers.