adriangb / di

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

feat: allow Dependant.cache_key customization to control cache hits from outer scopes #57

Closed adriangb closed 2 years ago

adriangb commented 2 years ago

This allows a "request" scoped dependency to use a value cached in the "app" scope

codecov-commenter commented 2 years ago

Codecov Report

Merging #57 (a6995b9) into main (93952df) will increase coverage by 0.53%. The diff coverage is 98.48%.

@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
+ Coverage   96.75%   97.28%   +0.53%     
==========================================
  Files          46       46              
  Lines        2000     2023      +23     
  Branches      338      344       +6     
==========================================
+ Hits         1935     1968      +33     
+ Misses         49       41       -8     
+ Partials       16       14       -2     
Impacted Files Coverage Δ
di/container.py 93.44% <88.88%> (ø)
di/_utils/execution_planning.py 100.00% <100.00%> (ø)
di/_utils/scope_map.py 100.00% <100.00%> (+19.23%) :arrow_up:
di/_utils/state.py 100.00% <100.00%> (ø)
di/_utils/task.py 98.80% <100.00%> (+2.43%) :arrow_up:
di/_utils/types.py 100.00% <100.00%> (ø)
di/api/dependencies.py 100.00% <100.00%> (ø)
di/dependant.py 97.33% <100.00%> (+0.07%) :arrow_up:
tests/test_caching.py 100.00% <100.00%> (ø)
tests/test_execute.py 95.53% <0.00%> (+0.55%) :arrow_up:
... and 1 more