that-depends
that-depends copied to clipboard
DI-framework, inspired by python-dependency-injector, but without wiring. Python 3.12 is supported
Common difficulty which currently requires some kind of "work-around" ```python @app.get("/") async def endpont(r: Request, value = fastapi.Depends(Container.provider)): ... ``` Where the provider is actually a dependent of the `Request`...
It would be a (small) DX boost not to have to write lifespan yourself. Applicable for FastAPI, Litestar and FastStream. ```python def create_container_lifespan(*containers: that_depends.BaseContainer): @contextlib.asynccontextmanager async def lifespan(*_args: typing.Any, **kwargs:...
Right now, all `Context` providers use `ContextVars` as storage. It would be good to have an alternative, for example, if someone needs more reliable persistence when working with asyncio. To-do:...
Some providers naming can be improved to make their intent more clear: Current suggestions: - `State` --> `ContextState`
Currently, `None` is the default value in most places where an argument can be omitted. In such cases, `None` just means the value has been left unset. It would be...