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.

@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.85%. Comparing base (3177d40) to head (4facb27).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #333      +/-   ##
==========================================
+ Coverage   96.83%   96.85%   +0.01%     
==========================================
  Files           1        1              
  Lines         601      604       +3     
  Branches      103      104       +1     
==========================================
+ Hits          582      585       +3     
  Misses         13       13              
  Partials        6        6              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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