Skip to content

Fix implicit ProviderOf lookup in child injectors - #333

Open
boyfeiyu wants to merge 1 commit into
python-injector:masterfrom
boyfeiyu:BOYF-588-providerof-child-locality
Open

boyfeiyu wants to merge 1 commit into
python-injector:masterfrom
boyfeiyu:BOYF-588-providerof-child-locality

Conversation

@boyfeiyu

@boyfeiyu boyfeiyu commented Nov 6, 2026

Copy link
Copy Markdown

When a parent injector resolves ProviderOf[T] before its child does, the cached implicit wrapper captures the parent injector. A later deferred lookup from the child can therefore ignore the child's binding override, making the result depend on lookup order.

Regenerate inherited implicit ProviderOf bindings in the requesting binder. Explicit bindings retain their original binder and scope. Regression tests cover lookup order, disabled auto-binding, constructor injection, injector hierarchies, lazy resolution, rebinding, errors, explicit bindings, singleton allocation, and assisted builders.

Validation on CPython 3.12.14 / macOS arm64:

  • Full suite: 175 passed; coverage 97.12% with branch measurement enabled.
  • The same nine-case reproduction: 6 failed / 3 passed on the base, 9 passed with the fix.
  • mypy 1.7.1, Black 26.10.1, and check-manifest 0.49 passed (manifest checked with existing build dependencies and --no-build-isolation).

The upstream CPython/PyPy Ubuntu matrix has not been run locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant