DanNduati/FastAPI-social-API

Pydantic BaseSettings priority customisation

Opened this issue · 1 comments

By default even when using a dotenv file, Pydantic will still read environment variables from your bash profile as well as the dotenv file, environment variables in the bash profile will always take priority over those in the dotenv file. I was able to override this behaviour when using python-dotenv however i have not been able to accomplish the same with pydantic. Here is a list of resources on the issue:

  1. https://pydantic-docs.helpmanual.io/usage/settings/#changing-priority
  2. https://towardsdatascience.com/how-to-manage-configurations-like-a-boss-34e224f3bb4
  3. pydantic/pydantic#1497
  4. https://rednafi.github.io/digressions/python/2020/06/03/python-configs.html

Reopened this because I took the lazy way out and just deleted the conflicting env. variable from my bash local env and called that a fix lol.