BlackSheep icon indicating copy to clipboard operation
BlackSheep copied to clipboard

Error using 3rd party dependency injector

Open goosedozer opened this issue 2 years ago • 1 comments

Library: dependency_injector (wriring) Error: TypeError: my_router() got multiple values for argument 'service' Code:

from deps import Deps, ProfileService
from dependency_injector.wiring import Provide, inject
from blacksheep import Application


app = Application()


@app.router.get("/")
@inject
async def my_router(service: ProfileService = Provide[Deps.profile_service]):
    return {"ok": True}


@app.on_start
async def on_start(_):
    print("start")
    Deps().wire(packages=[__name__])

Can this be fixed somehow?

goosedozer avatar Aug 15 '23 19:08 goosedozer

I think you may be better off using the first party solution to dependency injection. You could maybe wrap the business logic under the first party solution.

https://www.neoteroi.dev/blacksheep/dependency-injection/#introduction

kodecreer avatar Oct 01 '23 18:10 kodecreer