Repository navigation
Extend parent injector multibindings in child injectors - #324
DYNOSuprovo wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #324 +/- ##
==========================================
- Coverage 96.83% 96.40% -0.44%
==========================================
Files 1 1
Lines 601 612 +11
Branches 103 105 +2
==========================================
+ Hits 582 590 +8
- Misses 13 15 +2
- Partials 6 7 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for your contribution! I think this is something Injector should support. I'll just think one round about the implementation. |
|
If you're able to, please fix CI with a bit more coverage, and resolve the conflicts (sorry!). |
|
Thanks for the review and feedback @davidparsson! Glad to hear this aligns with Injector's goals. I will resolve the merge conflicts and add more test cases to increase CI coverage. |
Allow child injectors to inherit and extend multibindings registered on their parent injectors for both sequence and mapping multibinds. Fixes python-injector#297 Signed-off-by: DYNOSuprovo <DYNOSuprovo@users.noreply.github.com>
cd58440 to
8e6f24b
Compare
|
Rebased cleanly onto latest \master, resolved the conflict in \CHANGES, and added test coverage for edge cases (including child multibinds when the parent has no binding for that interface, and child multibinds when the parent has a non-multibinder binding). All 140 tests pass with full 100% branch and statement coverage on the new lines. |
Summary
Fixes #297.
Previously, when a child injector configured multibindings on an interface (such as
List[T]orDict[K, V]), a newMultiBinderwas instantiated without reference to the parent injector's multibinder. Consequently,child_injector.get()only retrieved the multibindings defined on the child, completely shadowing the parent's multibindings.This change:
BinderandinterfaceonMultiBinder.MultiBinder.get_scoped_providers(), checks if the owner binder has a parent binder with a registeredMultiBinderfor the same interface, yielding scoped providers from the parent first before yielding child providers.Tests
Added test cases in
injector_test.py:test_multibinds_are_extended_by_child_injectorstest_multibind_dict_is_extended_by_child_injectorstest_multibind_multi_level_hierarchy_extended_by_child_injectorstest_multibind_skipped_level_child_injector