Ididi

Latest version: v1.4.2

Safety actively analyzes 703125 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 8 of 10

0.2.7

Improvements:

- support sync resource in async dependent
- better error message for async resource in sync function
- resource shared within the same scope, destroyed when scope is exited

0.2.6

Feature:

- you can now use async/sync generator to create a resource that needs to be closed

python
from ididi import DependencyGraph
dg = DependencyGraph()

dg.node
async def get_client() -> ty.AsyncGenerator[Client, None]:
client = Client()
try:
yield client
finally:
await client.close()


dg.node
async def get_db(client: Client) -> ty.AsyncGenerator[DataBase, None]:
db = DataBase(client)
try:
yield db
finally:
await db.close()


dg.entry_node
async def main(db: DataBase):
assert not db.is_closed

0.2.5

Improvements:

- [x] better error message for node creation error
NOTE: this would leads to most exception be just NodeCreationError, and the real root cause would be wrapped in NodeCreationError.error.

This is because we build the DependencyNode recursively, and if we only raise the root cause exception without putting it in a error chain, it would be hard to debug and notice the root cause.

e.g.

bash
.pixi/envs/test/lib/python3.12/site-packages/ididi/graph.py:416: in node
raise NodeCreationError(factory_or_class, "", e, form_message=True) from e
E ididi.errors.NodeCreationError: token_bucket_factory()
E -> TokenBucketFactory(aiocache: Cache)
E -> RedisCache(redis: Redis)
E -> Redis(connection_pool: ConnectionPool)
E -> ConnectionPool(connection_class: idid.Missing)
E -> MissingAnnotationError: Unable to resolve dependency for parameter: args in <class 'type'>, annotation for `args` must be provided


Features:

0.2.4

Features:

- feat: support for async entry
- feat: adding `solve` as a top level api

Improvements:

- resolve / static resolve now supports factory
- better typing support for DependentNode.resolve
- dag.reset now supports clear resolved nodes

0.2.3

- [x] fix: change implementation of DependencyGraph.factory to be compatible with fastapi.Depends

- [x] fix: fix a bug with subclass of ty.Protocol

- [x] feat: dg.resolve depends on static resolve

- [x] feat: node.build now support nested, partial override

e.g.

python
class DataBase:
def __init__(self, engine: str = "mysql", /, driver: str = "aiomysql"):
self.engine = engine
self.driver = driver

class Repository:
def __init__(self, db: DataBase):
self.db = db

class UserService:
def __init__(self, repository: Repository):
self.repository = repository


node = DependentNode.from_node(UserService)
instance = node.build(repository=dict(db=dict(engine="sqlite")))
assert isinstance(instance, UserService)
assert isinstance(instance.repository, Repository)
assert isinstance(instance.repository.db, DataBase)
assert instance.repository.db.engine == "sqlite"
assert instance.repository.db.driver == "aiomysql"


- [x] feat: detect unsolveable dependency with static resolve

0.2.2

- [x] feat: adding py.typed file

Page 8 of 10

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.