Ididi
Genius simplicity, unmathced power.
ididi is 100% test covered and strictly typed.
No Container, No Provider, No Wiring, just Python
Information
Documentation: https://raceychan.github.io/ididi
Source Code: https://github.com/raceychan/ididi
Install
Usage
Quick Start
from ididi import use, entry, AsyncResource
async def conn_factory(engine: AsyncEngine) -> AsyncGenerator[AsyncConnection, None]:
async with engine.begin() as conn:
yield conn
class UnitOfWork:
def __init__(self, conn: AsyncConnection=use(conn_factory)):
self._conn = conn
@entry
async def main(command: CreateUser, uow: UnitOfWork):
await uow.execute(build_query(command))
await main(CreateUser(name='user'))
This would create a UnitOfWork
instance with a connection from conn_factory
when main
is called.
Why Ididi?
ididi helps you do this while stays out of your way, you do not need to create additional classes like Container
, Provider
, Wire
, nor adding lib-specific annotation like Closing
, Injectable
, etc.
ididi provides unique powerful features that most alternatives don't have, such as support to inifinite number of context-specific nested sopce, lazydependent, advanced circular dependency detection, plotting, etc.
Let's now explore these fantastic feaures in the Features
section.
To di, or not to di, this is my question
If you
- Are not familar with dependency injection, or OOP in general.
- Can't come up with cases where it would be useful.
- You fee like
it's java
and you havejavaphobia
.
Let's discuss in the Introduction
section.