This .envs file:
TESTING=TRUE
CONNECTION_ADDRESS="example.com"
CONNECTION_PORT=443
worked in Pydantic Settings 2.1 with this python code without problems:
from pydantic_settings import BaseSettings, SettingsConfigDict
class ConnectionSettings(BaseSettings):
model_config = SettingsConfigDict(env_prefix='connection_', env_file='.envs')
address: str
port: int
def get_conn_params() -> ConnectionSettings:
settings = ConnectionSettings() # pyright: ignore
print(settings)
return settings
# if executed as a script
if __name__ == "__main__":
get_conn_params()
But in Pydantic Settings 2.2 this error is thrown:
pydantic_core._pydantic_core.ValidationError: 1 validation error for ConnectionSettings
testing
Extra inputs are not permitted [type=extra_forbidden, input_value='TRUE', input_type=str]
In my opinion the setting env_prefix should imply, that inputs without this prefix are ignored.
I am not sure why else a prefix should be used.
This
.envsfile:worked in Pydantic Settings 2.1 with this python code without problems:
But in Pydantic Settings 2.2 this error is thrown:
In my opinion the setting
env_prefixshould imply, that inputs without this prefix are ignored.I am not sure why else a prefix should be used.