Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upChange BaseSettings defaults #721
Comments
This comment has been minimized.
This comment has been minimized.
I definitely agree about |
This comment has been minimized.
This comment has been minimized.
I've got extremely frustrated with aliases in
How do we work around this? I'd therefore like to completely change how environment variables are interpreted in from pydantic import BaseSettings
class Settings(BaseSettings):
pg_dsn: str = 'postgres://postgres@localhost:5432/app'
class Config:
fields = {'pg_dsn': {'env': {'DATABASE_URL', 'PG_DSN'}}}
# or using Field (#577):
class Settings(BaseSettings):
pg_dsn: str = Field('postgres://postgres@localhost:5432/app', env={'DATABASE_URL', 'PG_DSN'})
# creating manually for testing (here i can use the raw field name since alias hasn't changed):
settings = Settings(pg_dsn='postgres://postgres@localhost:5432/testing') as discussed on #747 thoughts? |
This comment has been minimized.
This comment has been minimized.
+1 In general aliases seem to make more sense to me in the context of |
This comment has been minimized.
This comment has been minimized.
I personally prefer the 2nd While the usage of |
This comment has been minimized.
This comment has been minimized.
Yes order of |
I would like to see these two BaseSettings Config fields default to the following:
Originally posted by @jasonkuhrt in #576 (comment)