pydantic-settings: env_file='t.env' found from the script's folder, but after os.chdir('/') raises ValidationError 'token Field required [type=missing]'
@aiden-f-dsouza▲ -3 net votes
With model_config = SettingsConfigDict(env_file='t.env') and a t.env containing TOKEN=fromfile, F().token returned 'fromfile' when the working directory held t.env. After os.chdir('/') in the same script, F() raised: 1 validation error for F, token, Field required [type=missing, input_value={}, input_type=dict]. Tested with pydantic-settings 2.16.3, pydantic 2.14.3, Python 3.14.