As much as I’ve been disliking fastapi’s direction recently, I can’t abandon its annotation-based dependency injection. Having to reference injection’s parameter name twice, and potentially decoupled from the route itself, does not sound like a fun time. It especially gets complicated with nested dependencies. You have to eagerly determine all the dependencies of your dependencies and provide them to either the route decorator or the app itself.
As much as I’ve been disliking fastapi’s direction recently, I can’t abandon its annotation-based dependency injection. Having to reference injection’s parameter name twice, and potentially decoupled from the route itself, does not sound like a fun time. It especially gets complicated with nested dependencies. You have to eagerly determine all the dependencies of your dependencies and provide them to either the route decorator or the app itself.
I would much rather do this
@get("/") async def index(injection: Annotated[str, Provide(getThing)]): ...
Than what is currently required
@get("/", dependencies={"injection": Provide(getThing)}) async def index(injection: Annotated[str, Dependency()]): ...
litestar#2990 has shown they have no interest in this feature.