pypi / pydantic-settings
pydantic-settings
What changed in pydantic-settings 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-19.
11 breaking3 security9 new APIs and options2 behavior and defaults36 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initpydantic-settings 261 changes
Breaking changes 11
With case_sensitive=False, only registered CLI options are lowercased; arguments after -- and CliUnknownArgs values keep their case.
Each CliUnknownArgs field now receives only leftover arguments from its own subcommand.
An empty JSON array now parses as an empty list instead of [''].
JSON config files are read as UTF-8 by default instead of the locale encoding; this option still overrides it.
With this enabled, a discriminated union default is dropped only when the incoming value selects a different union member.
Python 3.10 is no longer supported; pydantic-settings now requires Python 3.11+.
When false, aliases are ignored in every source; environment variables, secrets, CLI flags and defaults use only field names.
Takes precedence over alias when the two differ, so JSON/YAML/TOML file and CLI values load instead of being silently ignored.
YAML config files are read as UTF-8 by default instead of the locale encoding; this option still overrides it.
The setting now applies to init kwargs and JSON/TOML/YAML config-file sources; because it defaults to False, matching is case-insensitive for these sources. Nested keys remain case-sensitive.
Non-JSON environment values for strict fields now raise
ValidationErrorinstead of a less specific error.
Security 3
With
case_sensitive=True, the GCP source skips thelist_secretscall, lowering the required IAM permissions toroles/secretmanager.secretAccessor.The source no longer follows symlinks that point outside
secrets_dir.pydantic-settings: NestedSecretsSettingsSource follows symlinks outside secrets_dir, enabling local file read and bypassing secrets_dir_max_size
New APIs and options 9
Adds an extra for installing the AWS Systems Manager Parameter Store source.
Adds an AWS Systems Manager Parameter Store source that recursively reads parameters under an ssm_path, mapping / onto nested models.
Adds named variadic CLI options that accept multiple values after one option as well as repeated options; required fields need at least one value.
Returns a process-local singleton per settings class; calling the class directly still builds a fresh instance.
Clears the cache used for process-local cached settings instances.
Enables environment variable names to appear in generated CLI help, making
--helpoutput useful as configuration documentation.Set this environment variable to a truthy value with
DEBUGlogging enabled to inspect source contributions, value precedence, and env-file or secret-file resolution.Lets you root settings at a nested table in any TOML file, rather than only in
pyproject.toml.JSON, TOML, and YAML file sources accept
Traversableresources, allowing packaged configuration files, including files in zip or wheel distributions, to be loaded without casting toPath.
Behavior and default changes 2
Fields with unresolved forward references now emit this warning, which tells you to call
model_rebuild(); warning-as-error configurations may turn it into a failure.The GCP settings source can obtain
project_idfrom an earlier settings source, rather than only from the constructor orGOOGLE_CLOUD_PROJECT.
Fixes and other changes 36
A bare single-segment AliasPath no longer tries to JSON-decode plain string values.
Resolving a named Annotated type alias no longer mutates shared FieldInfo metadata, avoiding validators running twice on subclasses or after model_rebuild().
Case-insensitive matching now works for nested pydantic dataclasses.
Tuples, frozenset, MutableSequence and other collection subtypes, including named collection type aliases, are treated as repeatable or variadic options.
cli_exit_on_error=False is now honored by CliSubCommand parsers, which raise SettingsError instead of exiting.
No longer crashes when cli_prefix is set in model_config.
Serialized output now round-trips through CliApp.run for enums, tuples, dates, Decimal values, explicit None, empty containers, CliVariadicArg values, and populated CliUnknownArgs fields.
Serialization now preserves explicit None values.
Serialization now preserves empty containers.
Serialization now handles populated CliUnknownArgs fields without raising IndexError.
Serialized CLI output now parses for enums, tuples, dates and Decimal values.
Serialization now preserves CliVariadicArg values.
Aliases keep their case when case_sensitive=False.
Set, MutableSet and AbstractSet fields now JSON-decode environment values.
dash_to_underscore=True now works for nested Azure Key Vault model fields.
DotenvFiltering is now exported from pydantic_settings.sources.types.
A bare typing.Dict field no longer raises IndexError when env_nested_delimiter is set.
Azure Key Vault and GCP Secret Manager now honor env_parse_none_str.
With extra='allow', a non-lowercase env_prefix is now stripped from dotenv extras.
An empty JSON config file is treated as an empty mapping instead of crashing.
Named union type aliases now decode like inline equivalents in environment and dotenv sources, including under Optional, Annotated and custom validation aliases.
The source now validates its specific constructor arguments.
Adds support for pydantic 2.14, including fixes for CliApp.run and validate_by_alias=False handling.
Adds support for Python 3.15.
secrets_case_sensitive=True is now honored on Windows.
An explicit empty tuple overrides the model config to read the TOML file root.
Home-directory paths are expanded when checking whether the TOML table-header file exists.
Environment values for nested model fields using
AliasPathare now JSON-decoded.Environment variables now load on Windows when
case_sensitive=True, despiteos.environkeys being upper-cased.Dotenv extras are no longer wrongly claimed by a complex field that shares their name prefix.
Enum names now parse through nested annotations such as
Optional[Annotated[MyEnum, ...]]when enum parsing is enabled.Case-insensitive field matching now works for optional nested models.
Secret subclasses no longer crash when loaded from the environment.
Secret files are now read as UTF-8 rather than using the platform locale encoding, avoiding corruption of non-ASCII secrets on some Windows code pages.
This package is no longer required at runtime.
An empty section now falls back to defaults instead of raising an
AttributeError.