-
-
Notifications
You must be signed in to change notification settings - Fork 340
Open
Description
Description
While trying to inject a provider.Aggregate into my FastAPI endpoint I discovered that using the marker pattern: Provider[foo] does not work as expected, contrary to what the documentation indicates docs
Example
class ServiceA
...
class ServiceB
...
class Container(containers.DeclaritiveContainer):
serviceA = providers.Factory(ServiceA)
serviceB = providers.Factory(ServiceB)
services = providers.Aggregate(serviceA=serviceA, serviceB=serviceB)
container = Container()
container.wire(modules=[__name__])
@router.post("/v1")
@inject
async def my_endpoint(dummy: TestPost, service=Depends(Provide[Container.services])): # <-- TypeError: missing 1st required positional argument: "provider name"
...
# However, this works:
@router.post("/v1")
@inject
async def my_endpoint(dummy: TestPost, service=Depends(Provide[Container.services.provider])): # <-- Works as expected
...Metadata
Metadata
Assignees
Labels
No labels