Scopes¶
- class diwire.ScopedContainer(_container: Any, _scope_id: _ScopeId)[source]¶
A context manager for scoped dependency resolution.
Supports both sync and async context managers: - with container.enter_scope() for sync usage - async with container.enter_scope() for async usage with proper async cleanup
Also supports imperative usage: - scope = container.enter_scope() to activate immediately - scope.close() or scope.aclose() to close explicitly - container.close() or container.aclose() to close all active scopes
- enter_scope(scope_name: str | None = None) ScopedContainer[source]¶
Start a nested scope.