Skip to content

0.68.0

Choose a tag to compare

@antonrh antonrh released this 22 Jan 18:50
· 153 commits to main since this release
0adc545

What's Changed

CLI Tool

New command-line interface to validate and visualize dependency graphs:

anydi myapp:container

Output formats:

  • tree (default) - ASCII tree representation
  • mermaid - Mermaid diagram format
  • dot - Graphviz DOT format
  • json - 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 myapp

#271, #273

Lazy 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.

#257, #274

Container Scanning

Added ignore argument to scan() method to skip specific packages or modules.

#279

Testing Support

Added container.test_mode() context manager to allow overriding dependencies during tests.

#276, #277, #278

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`...

#272

Deprecations

The following parameters are deprecated and will be removed in a future version:

  • interface parameter → use dependency_type instead
  • call parameter → use factory instead

#269

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)

#267

Full Changelog: 0.67.2...0.68.0