adriangb / di

Pythonic dependency injection
https://www.adriangb.com/di/
MIT License
301 stars 13 forks source link

BREAKING_CHANGE: dissallow using a dependency with different scopes #61

Closed adriangb closed 2 years ago

adriangb commented 2 years ago

Closes #58.

This change explicitly prohibits using the same dependency with multiple scopes within a given DAG, thus resolving #58.

It is important to note the within a given DAG part: you can still use the same dependency in two completely separate DAGs with different scopes. In this case, caching between them will work: if the dependency is cached in an outer scope, the cached value will be used, but if it is cached in an inner scope, it will be ignored (this behavior is here)

codecov-commenter commented 2 years ago

Codecov Report

Merging #61 (d8cefe6) into main (c988f5c) will increase coverage by 0.05%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #61      +/-   ##
==========================================
+ Coverage   97.28%   97.33%   +0.05%     
==========================================
  Files          46       46              
  Lines        2023     2028       +5     
  Branches      344      344              
==========================================
+ Hits         1968     1974       +6     
  Misses         41       41              
+ Partials       14       13       -1     
Impacted Files Coverage Δ
tests/test_dependant.py 100.00% <ø> (ø)
di/container.py 93.97% <100.00%> (+0.47%) :arrow_up:
di/dependant.py 97.29% <100.00%> (ø)
tests/test_solving.py 97.29% <100.00%> (+0.04%) :arrow_up: