Код: Выделить всё
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
from devtools import debug
class Config(BaseSettings):
# Environment
STAGE: str = Field('prod', validation_alias='STAGE')
OTHER: str
model_config = SettingsConfigDict(env_file='.test.env', env_file_encoding='utf-8', env_prefix='DEV_')
settings = Config()
debug(settings)
Код: Выделить всё
STAGE=test
DEV_OTHER="other"
Код: Выделить всё
export STAGE=dev
Код: Выделить всё
...
STAGE=dev
...
Код: Выделить всё
test.py:18
settings: Config(
STAGE='test',
OTHER='other',
)
Подробнее здесь: https://stackoverflow.com/questions/786 ... nvironment