pypi / pydantic-core
pydantic-core
What changed in pydantic-core 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-21.
72 breaking8 deprecations10 new APIs and options4 behavior and defaults16 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initpydantic-core 2110 changes
Breaking changes 72
Fields annotated as Any no longer default to None and are required unless an explicit default is provided.
Url and Dsn types no longer inherit from str; convert them with str(url) when using APIs that expect a string.
Coercing int, float, and Decimal values to strings is optional and disabled by default.
Color Types have moved to the separately installable Pydantic Extra Types package.
This config setting has been removed.
Vanilla dataclasses no longer inherit the parent type's config; override config with the config parameter on the @dataclass decorator.
Pydantic dataclasses no longer support extra='allow'; extra='ignore' remains supported but does not store extra fields.
Dataclasses used as fields no longer accept tuples as validation inputs; use dictionaries instead.
Decimal is represented as a string in generated JSON schema and serialization.
This config setting has been removed.
Arbitrary keyword arguments are no longer added to JSON schema; pass extra schema data through json_schema_extra instead.
Use frozen instead.
The const property has been removed.
Constraints are no longer automatically pushed down to generic parameters; use typing.Annotated to annotate the parameter type.
Use the typing.Final type hint instead.
Use max_length instead.
Use min_length instead.
Use pattern instead.
Introduced as the replacement for validator, with new features; annotate generic container item types to validate their contents.
Validator functions no longer receive the config argument; access configuration through info.config instead.
Validator functions no longer receive the field argument; use info.field_name to look up the field in cls.model_fields.
Returns None when no alias is set, rather than returning the field name.
This config setting has been removed; use Annotated on fields to modify them.
Float values convert to integers only when their decimal part is zero, avoiding loss of fractional data.
Renamed from orm_mode.
Removed; generic BaseModel subclasses can now inherit from Generic directly.
Custom types should use __get_pydantic_core_schema__ in place of __get_validators__.
Custom JSON schema hooks use __get_pydantic_json_schema__ in place of __modify_schema__.
Removed because orm_mode and its implementation detail are no longer supported.
Removed along with orm_mode; it was an implementation detail of that feature.
Renamed from keep_untouched.
Validated generic collections are no longer guaranteed to preserve their input subtype; output types match the annotations, while BaseModel subclasses and dataclasses retain their types.
Iterables of pairs, including empty iterables, are no longer coerced to dictionaries during validation.
This config setting has been removed.
JSON serialization of non-string dictionary keys generally uses str(key), changing output for values such as None.
This config setting has been removed.
Renamed from schema_extra; also used to pass extra JSON schema data to Field.
Replaces construct() as the model construction method.
Replaces copy() as the model copying method.
Replaces dict() as the method for dumping model data.
Replaces json() for JSON serialization; output is compacted and may not exactly match json.dumps() output.
Models are equal only to BaseModel instances with matching type, field values, extra values, and private attribute values; they are no longer equal to dictionaries containing their data.
Replaces __fields__ as the name for model fields.
Replaces json_schema() as the model JSON schema method.
Replaces update_forward_refs() as the model rebuilding method.
Provides the JSON-loading behavior that previously came from parse_raw.
Generated JSON schema no longer preserves namedtuples as namedtuples.
An Optional-annotated field without a default is required but accepts None; Optional no longer implies a default of None.
The parse_env_var classmethod has been removed; customize settings sources to provide a parsing function.
Payment Card Numbers have moved to the separately installable Pydantic Extra Types package.
Renamed from allow_population_by_field_name.
Pydantic dataclass __post_init__ is now called after validation rather than before.
This config setting has been removed.
Removed because it became redundant after __post_init__ moved after validation.
Pydantic dataclasses no longer expose this attribute or use an underlying BaseModel; use TypeAdapter for related functionality.
Replaces __private_attributes__ as the name for private attributes.
Replaces __validators__ as the model validator attribute.
Deprecated in favor of model_validator; even when retained, skip_on_failure=False is no longer supported.
Replaces the __root__ field for defining a custom root model; RootModel types do not support arbitrary_types_allowed.
Removed; the default union_mode in Pydantic V2 is 'smart'.
Renamed from max_anystr_length.
Renamed from min_anystr_length.
Renamed from anystr_strip_whitespace.
Renamed from anystr_lower.
Renamed from anystr_upper.
Nested model serialization includes only fields defined on the annotated field type, rather than all fields from a subclass instance.
A TypeError raised in a validator is no longer converted into a ValidationError, preventing programming errors from being reported as validation failures.
Removed because Pydantic V2 behaves as though this setting were always True.
Set union_mode='left_to_right' on Field to restore the non-short-circuiting left-to-right union behavior.
URL validation appends a slash when a URL has no path, even if the input omitted the slash.
The decorator formerly named @validate_arguments is now @validate_call; attributes such as raw_function and validate are not preserved.
Renamed from validate_all and can be used to validate defaults, including as an alternative to validator always=True behavior.
Deprecations 8
Invalid *after* model validator function signatures now emit a deprecation warning instead of raising an error.
The V1 pattern of defining a Config class in a BaseModel subclass is deprecated; use model_config instead.
Deprecated; model_validate can provide similar behavior when from_attributes=True is set in the model config.
Support for specifying json_encoders in model config is deprecated; serialization decorators are recommended for common custom serialization scenarios.
The notes advise against isinstance checks against parametrized generics; subclass the parametrized generic if such checks are needed.
Deprecated; load the data and pass it to model_validate.
Deprecated; use model_validate_json for JSON input or load the data before passing it to model_validate.
Deprecated in favor of field_validator; the each_item keyword is unavailable on field_validator, and validator signatures can no longer include field or config arguments.
New APIs and options 10
Adds a method to convert FieldInfo to a dictionary.
Adds a decorator for customizing serialization.
Generic BaseModel subclasses can be declared by adding Generic as a parent class; mixing V1 and V2 models is not supported.
Choose whether generated JSON schema represents validation inputs or serialization outputs.
Specify model configuration with a class attribute dictionary; inherited configuration is merged across BaseModel parents, with later parents taking precedence for duplicate settings.
Replaces parse_obj() for validating model input and can be used in place of from_orm when from_attributes=True.
Introduced as the replacement for root_validator; under some circumstances it receives a model instance rather than a values dictionary.
JSON schema generation methods accept schema_generator so callers can provide a custom GenerateJsonSchema subclass.
Wrap dataclasses with TypeAdapter to validate, generate JSON schema, or access functionality previously requiring __pydantic_model__.
Use typing.Annotated to add custom validation or provide custom core-schema and JSON-schema functions without modifying the type itself.
Behavior and default changes 4
The allow_reuse keyword argument is no longer necessary; repeated-function detection now errors only for redefinition within a single class.
Generated JSON schema now targets draft 2020-12 by default, with some OpenAPI extensions.
Constructor arguments may be copied during validation and coercion, which matters when passing mutable objects.
Union validation preserves the input type when it matches a choice, even when that choice is not first in the union.
Fixes and other changes 16
Fix missing GC traversal on some struct fields and in GeneralFieldsSerializer.
Validated model fields are counted once in smart unions.
Validators can be reused when plugins are set.
Preserve RootModel core metadata.
Handle AttributeError subclasses when from_attributes is used.
Fixes
ValidationInfo.field_namebeing missing when usingmodel_validate_json().Fixes
ValidationInfo.databeing missing when usingmodel_validate_json().Fixes a pickle error when using model_construct() on a model with MISSING as a default value.
Reverted URL credential percent-encoding in the
build()method ofAnyUrlandDsntypes.Validation no longer gets default values from
defaultdict, fixing a regression in its validation behavior.Fields with
exclude_ifare excluded from JSON Schema required fields.Fixed serialization of IP address types to JSON when
serialize_as_anyis used by adding type inference.Fixed forward references in parent TypedDict classes on Python 3.14 and greater.
Fixed field serializers on nested typed dictionaries.
Mutations on FieldInfo classes reused as Annotated metadata are supported again, although this remains an unsupported pattern.
Generated JSON schema for Optional fields now indicates that null is allowed.