Closed
Description
I'm using Dependency injector on my FastAPI Project.
currently using FastAPI
while Injecting some packages on FastAPI + SQLAlchemy + DI Project, for example
@router.get("/users")
@inject
def get_users(
user_service: UserService = Depends(Provide[Container.user_service])
) -> List[UserModel] :
some..codes..
I inject dependencies with non-annotated style codes.
can I do it with annotated style, like for example
userService = Annotated[UserService, Depends(Provide[Container.user_service])]
@router.get("/users")
@inject
def get_users(user_service: userService) -> List[UserModel] :
some..codes..
It doesn't works well, with following errors.
AttributeError: 'Provide' object has no attribute 'get_all'
Think it finds dependency from Provide.
is there any way to use annotated style like above?
Metadata
Metadata
Assignees
Labels
No labels