Repository navigation
Closed
Labels
enhancementNew feature or requestNew feature or requestready-for-agentFully specified, ready for an AFK agentFully specified, ready for an AFK agent
Milestone
Description
This was generated by AI during a pre-4.0 audit of main at 9cd88e7.
Observation
Containerexposesproviders_registry,cache_registry,context_registry,overrides_registryand a writableclosedas public attributes (container.py:43-53). Outside code can swap or mutate them.overrides_registryis alwaysproviders_registry.overrides(container.py:91-102): two names for one object.- Bug:
Container(scope=Scope.REQUEST, parent_container=root, groups=[G])registersGinto the tree-wide registry, bypassing theChildContainerRegistrationErrorguard thatadd_providersenforces (container.py:103-107,:205). Reproduced. resolvechecksclosedafter the registry lookup,resolve_providerbefore it (container.py:143vs:166): a closed container asked for an unregistered type raisesProviderNotRegisteredError, notContainerClosedError.:147uses_providers[...]while:150usesfind_provider.- There is no public provider lookup: modern-di-grpc
modern_di_grpc/main.py:45callscontainer.providers_registry.find_provider. build_child_container,find_container,close_*andreset_overridehave no contract docstrings (AGENTS.md asks for them).
Proposal
- Add public
Container.find_provider(type) -> AbstractProvider | None(name to confirm). - Make the registries private; one name for the overrides registry.
closedbecomes a read-only property.- Raise
ChildContainerRegistrationErrorwhengroupsis passed withparent_container(failing test first). - Check
closedfirst in bothresolveandresolve_provider(failing test first). - Contract docstrings for the listed methods.
Acceptance
Tests for each bullet; docs/providers/scopes.md and advanced-api.md no longer document registry attributes; migration guide entries. Follow-up for modern-di-grpc is tracked in the integrations issue.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestready-for-agentFully specified, ready for an AFK agentFully specified, ready for an AFK agent
Activity
feat!: tighten Container's public surface (#565)