-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Issue derived from #275
Currently BaseSettings defaults to looking for env variables in uppercase. This issue is a feature proposal to make this behaviour configurable.
The current workaround is to use the settings config class to set up aliases, e.g.:
class S(pydantic.BaseSettings):
test:str
class Config:
fields = dict(test=dict(alias="test"))However this is verbose and onerous to do (for the developer), if there are many such env vars.
It would be nice if the developer could do something like:
class S(pydantic.BaseSettings):
class Config:
letter_case = "lower" # or: "upper" | "any"
test:strAbout this concern raised for case insensitive option #275 (comment).
- we could log a warning or raise an error at a certain configurable threshold of
- env var count
- or perhaps based on measured processing time exceeding configurable budget (e.g. 1ms)
- we could cache the calculation of
env2(but probably the entire settings result would just be cached by the app) - the env prefix could help reduce the amount of work needed to do