Closed ofek closed 1 year ago
Hi @ofek, the way I'm currently doing it can be found here (basically defining a custom source, and rearranging the order in customise_sources
). The only drawback is that I can't specify the filename (it is read from an envvar), but this might be useful still for your use case.
I've got a working implementation here that might be of interest:
The codebase is a mess, but it works.
Among other things it:
If there's interest, I'd love to be able to clean it up and merge into pydantic-settings.
Right now I'm in the process of updating it to pydantic V2
It is possible to have a custom settings source class beside the internal pydantic-settings
source classes.
You can find the related docs here : https://docs.pydantic.dev/latest/concepts/pydantic_settings/#customise-settings-sources
Awesome, thank you!
https://github.com/pydantic/pydantic/issues/1676
Feature Request
My use case is I'm reading a toml config file and passing what is read directly to the model constructor. However, I have no way to allow users env var or .env overrides.
Essentially, configs persisted to disk cannot benefit from BaseSettings.