Advanced / low-level API¶
Lower-level public surface for library authors and advanced use-cases.
Container attributes and methods¶
find_container(scope)— walksscope_mapand returns the container registered atscope; raisesScopeNotInitializedErrororScopeSkippedErrorif the scope is absent.parent_container— constructor kwarg and slot; the direct parent of a child container, orNonefor a root. Passing ascope ≤ parent.scoperaisesInvalidChildScopeError.scope_map—dict[IntEnum, Container]mapping every scope in the chain to its container; built at construction time and inherited (plus the new scope) by each child.lock— athreading.RLockinstance, orNonewhen the container was created withuse_lock=False. The lock gates singleton creation insideFactory.resolve.
Group.get_providers()¶
Group.get_providers() is a classmethod that traverses the MRO (excluding Group and
object) and collects every class attribute that is an AbstractProvider instance, respecting
MRO override order (subclass attribute shadows parent attribute of the same name). Use it to
inspect or iterate all providers declared on a group hierarchy.
Subclassing AbstractProvider¶
To implement a custom provider, subclass AbstractProvider and implement:
resolve(container)(required) — returns the resolved instance.get_dependencies(container)(optional) — returns adict[str, AbstractProvider]mapping parameter names to their providers; used byContainer.validate()for graph traversal.iter_validation_issues(container)(optional) — yieldsExceptioninstances for validation-time problems found in this provider; default yields nothing.effective_scope(container)(optional override) — override this method to report the scope of whatever the provider ultimately resolves to. A transparent or redirect provider (likeAlias) should override it to follow the source chain so thatContainer.validate()checks callers against the real target scope rather than any nominal scope on the wrapper itself.
CacheSettings.is_async_finalizer¶
CacheSettings.is_async_finalizer is a computed bool field set at construction time via
inspect.iscoroutinefunction(finalizer). Factory.resolve and the cache registry use it to
decide whether to await the finalizer during close_async() or treat it as sync.