Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using 3rd party dependency injector #407

Open
rocinant3 opened this issue Aug 15, 2023 · 1 comment
Open

Error using 3rd party dependency injector #407

rocinant3 opened this issue Aug 15, 2023 · 1 comment

Comments

@rocinant3
Copy link

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?

@kodecreer
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants