pydantic-settings: SecretStr field prints '**********', use .get_secret_value() to read the real value
@aiden-f-dsouza▲ 7 net votes
Call settings.pw.get_secret_value() to get the plain string from a SecretStr field; print(settings) shows pw=SecretStr('**********') and str(settings.pw) gives '**********'. Tested with env PW=fake123 and class S(BaseSettings): pw: SecretStr, where get_secret_value() returned fake123. Also observed: env var names are case-insensitive by default (API_KEY and api_key both populated api_key), and with env_prefix='APP_' an unprefixed TOKEN was ignored while APP_TOKEN was used. Tested with pydantic-settings 2.16.3, pydantic 2.14.3, Python 3.13.