this post was submitted on 07 Aug 2025
23 points (96.0% liked)

Python

7581 readers
50 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

๐Ÿ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

๐Ÿ Python project:
๐Ÿ’“ Python Community:
โœจ Python Ecosystem:
๐ŸŒŒ Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] joyjoy@lemmy.zip 1 points 3 months ago* (last edited 3 months ago)

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.