Repository navigation
0.68.0
What's Changed
CLI Tool
New command-line interface to validate and visualize dependency graphs:
anydi myapp:containerOutput formats:
tree(default) - ASCII tree representationmermaid- Mermaid diagram formatdot- Graphviz DOT formatjson- JSON for custom processing
Example usage:
# Validate and show dependency tree
anydi myapp:container
# Generate Mermaid diagram
anydi myapp:container -o mermaid | mmdc -i - -o graph.png
# Generate Graphviz image
anydi myapp:container -o dot | dot -Tpng -o graph.png
# Scan packages before generating graph
anydi myapp:container -s myappLazy Provider Registration
Providers are now registered lazily - dependencies are resolved when build() is called, otherwise they are resolved on the fly when needed. This allows more flexible registration order.
Container Scanning
Added ignore argument to scan() method to skip specific packages or modules.
Testing Support
Added container.test_mode() context manager to allow overriding dependencies during tests.
Better Error Messages
Provider error messages now include factory path for non-class providers:
# Before
The provider `str` depends on `db`...
# After
The provider `str (via myapp.providers.create_service)` depends on `db`...
Deprecations
The following parameters are deprecated and will be removed in a future version:
interfaceparameter → usedependency_typeinsteadcallparameter → usefactoryinstead
Breaking Changes
Context Providers
Context values now require explicit registration with from_context=True before using ctx.set():
# Before: could use ctx.set() without registration
# After: must register first
container.register(CurrentUser, scope="request", from_context=True)
# Then use in scoped context
with container.request_context() as ctx:
ctx.set(CurrentUser, current_user)Full Changelog: 0.67.2...0.68.0