pydantic / pydantic-settings

Settings management using pydantic
https://docs.pydantic.dev/latest/usage/pydantic_settings/
MIT License
593 stars 61 forks source link

fix: superfluous deep env conflicts with non-dict model leaf #276

Closed diefans closed 5 months ago

diefans commented 5 months ago

If a model defines a leaf as e.g. a string and the user or system sets an environment var with an additional env_nested_delimiter + suffix, explode_env_vars was treating the string as a dict (trying to add an item to it).

This fix checks if the target is indeed a dict.

In that regard, the whole explode_env_vars seems a bit wasteful, in terms of possible throwing away already computed values, if a deeper environment variable is processed earlier (which is possible, since the iteration order of os.environ seems unpredictable).

resolves #275

diefans commented 5 months ago

test setup seems broken for mac/python 3.8/3.9 image

hramezani commented 5 months ago

test setup seems broken for mac/python 3.8/3.9 image

Got fixed in https://github.com/pydantic/pydantic-settings/commit/a4aadfd9818fc1ea51bc8f0e84573b136a94e735 Please reabase your PR

diefans commented 5 months ago

@hramezani

Please reabase your PR

done