BlackSheep
BlackSheep copied to clipboard
Error using 3rd party dependency injector
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?
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