pydantic-settings icon indicating copy to clipboard operation
pydantic-settings copied to clipboard

Pass current_state in when calling custom and built-in sources.

Open mnbbrown opened this issue 1 year ago • 2 comments

This will allow sources to dynamically decided if to provide a value for the attribute. For example, a higher priority source can decided to leave the low-priority source "as is" if it's not None.

Note: I think this is considered a breaking change as the signature of __call__ on the source abstract type is changing.

See https://github.com/pydantic/pydantic-settings/issues/223#issuecomment-1913196648 for context Interested in the maintainers thoughts here :)

mnbbrown avatar Jan 27 '24 15:01 mnbbrown

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (40230ab) 97.69% compared to head (e024247) 97.71%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #224      +/-   ##
==========================================
+ Coverage   97.69%   97.71%   +0.01%     
==========================================
  Files           5        5              
  Lines         347      350       +3     
  Branches       76       76              
==========================================
+ Hits          339      342       +3     
  Misses          6        6              
  Partials        2        2              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 27 '24 15:01 codecov[bot]

Thanks @mnbbrown for this PR.

we need some tests for this and have to wait to merge it before V3 because it is a breaking change.

hramezani avatar Jan 29 '24 08:01 hramezani

Superseded by https://github.com/pydantic/pydantic-settings/pull/326

hramezani avatar Jul 07 '24 14:07 hramezani