You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched (google, github) for similar issues and couldn't find anything
I have read and followed the docs and still think this feature/change is needed
After submitting this, I commit to one of:
Look through open issues and helped at least one other person
Hit the "watch" button on this repo to receive notifications and I commit to help at least 2 people that ask questions in the future
Implement a Pull Request for a confirmed bug
Feature Request
Currently, there is field value priority (from the docs):
In the case where a value is specified for the same Settings field in multiple ways, the selected value is determined as follows (in descending order of priority):
Arguments passed to the Settings class initialiser.
Environment variables, e.g. my_prefix_special_function as described above.
Variables loaded from a dotenv (.env) file.
The default field values for the Settings model.
However, in some cases it would be nice to swap 1 and (2,3) priorities. For example, I would like to create the configuration system based on config files (YAML, TOML, INI, etc) and env vars where envvars/dotenv have highest priority (env vars override values from config files that looks reasonable in some cases just like now env vars (2) override dotenv file (3)).
In this case values from config file will override values from env vars.
Currently, the default behavior cannot be changed without subclassing BaseSettings class and overriding _build_values method. This is not mentioned in the current docs but previously it was mentioned (see pydantic/pydantic#340, pydantic/pydantic#341, pydantic/pydantic#343).
Would you mind considering the customization of this behavior via Config of BaseSettings model?
The text was updated successfully, but these errors were encountered:
Perhaps a way this would work would be to introduce a new Config option for BaseSettings, e.g. env_has_prio which would default to False. If True the order would become 2, 3, 1, 4. I don't think there is a use case for lifting .env above env vars.
Checks
Feature Request
Currently, there is field value priority (from the docs):
However, in some cases it would be nice to swap 1 and (2,3) priorities. For example, I would like to create the configuration system based on config files (YAML, TOML, INI, etc) and env vars where envvars/dotenv have highest priority (env vars override values from config files that looks reasonable in some cases just like now env vars (2) override dotenv file (3)).
It might look something like this:
In this case values from config file will override values from env vars.
Currently, the default behavior cannot be changed without subclassing
BaseSettings
class and overriding_build_values
method. This is not mentioned in the current docs but previously it was mentioned (see pydantic/pydantic#340, pydantic/pydantic#341, pydantic/pydantic#343).Would you mind considering the customization of this behavior via
Config
ofBaseSettings
model?The text was updated successfully, but these errors were encountered: