unstale

pypi / pydantic

pydantic

What changed in pydantic 1 to 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-04.

103 breaking2 security16 deprecations17 new APIs and options5 performance6 behavior and defaults3 tooling48 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

pydantic 2191 changes

Breaking changes 100

  • Validation now disallows extra keys that are not strings.

    2.14.3release notes

  • GraalPy 3.11 wheels are no longer published because they were not working due to a PyO3 version bump.

    2.14.3release notes

  • Attribute docstrings are no longer extracted from nested classes and functions.

    2.14.2release notes

  • With extra=allow, extra data matching a field name is ignored for dataclasses.

    2.14.2release notes

  • JSON validation now handles field lookup and extra data like Python validation; keys matching only an unused alias or field name are treated as extra data instead of being silently dropped.

    2.14.2release notes

  • Mapping max_length constraints are now checked during validation.

    2.14.2release notes

  • With extra=allow, extra data matching a field name is ignored for TypedDict values.

    2.14.2release notes

  • Rejects out-of-range int inputs for timedelta.

    2.14.1release notes

  • Enum constructors are called in both validation modes.

    2.14.0release notes

  • Fraction validation rejects large exponents.

    2.14.0release notes

  • JSON Schema defaults are encoded with a consistent configuration.

    2.14.0release notes

  • multiple_of constraints must be positive.

    2.14.0release notes

  • NameEmail validation rejects newlines.

    2.14.0release notes

  • Python 3.9 is no longer supported.

    2.14.0release notes

  • Serialization inference no longer applies ser_json_timedelta to all datetime types.

    2.14.0release notes

  • The config setting has been renamed to populate_by_name.

    2.0.0upgrade guide

  • The allow_reuse keyword argument is no longer necessary because repeated-function detection now errors only for redefinition within a single class.

    2.0.0upgrade guide

  • Fields annotated as Any no longer have an implicit default value of None.

    2.0.0upgrade guide

  • The config setting has been renamed to str_to_lower.

    2.0.0upgrade guide

  • The config setting has been renamed to str_strip_whitespace.

    2.0.0upgrade guide

  • The config setting has been renamed to str_to_upper.

    2.0.0upgrade guide

  • Url and Dsn types no longer inherit from str, so convert them with str(url) when using APIs that expect a string.

    2.0.0upgrade guide

  • Coercion of int, float, and Decimal values to strings is optional and disabled by default.

    2.0.0upgrade guide

  • Constrained* classes were removed; replace constrained types with Annotated and Field(...).

    2.0.0upgrade guide

  • Constrained* classes were removed; StringConstraints is an alternative for constrained strings.

    2.0.0upgrade guide

  • The copy_on_model_validation config setting has been removed.

    2.0.0upgrade guide

  • Vanilla dataclasses no longer inherit the parent type's config; configure them with the config parameter on the @dataclass decorator.

    2.0.0upgrade guide

  • Dataclasses used as fields no longer accept tuples as validation input; use dictionaries instead.

    2.0.0upgrade guide

  • Fields typed as dict no longer accept iterables of pairs, including empty iterables.

    2.0.0upgrade guide

  • Support for email-validator versions below 2.0.0 was dropped; update the package.

    2.0.0upgrade guide

  • Models compare equal only to BaseModel instances with matching type, field values, extra values, and private attribute values; they are no longer equal to data dictionaries.

    2.0.0upgrade guide

  • The error_msg_templates config setting has been removed.

    2.0.0upgrade guide

  • Pydantic dataclasses no longer support extra='allow' for storing unexpected initializer fields as extra attributes.

    2.0.0upgrade guide

  • Field no longer accepts arbitrary keyword arguments for JSON schema extras; pass extra data in the json_schema_extra dictionary argument.

    2.0.0upgrade guide

  • field_validator replaces validator and does not accept each_item; annotate generic container item types to validate them.

    2.0.0upgrade guide

  • The validator argument config was removed; use info.config to access configuration.

    2.0.0upgrade guide

  • The validator argument field was removed; access field information through info.field_name and cls.model_fields.

    2.0.0upgrade guide

  • Field.alias returns None when no alias is set, instead of returning the field's name.

    2.0.0upgrade guide

  • Field.allow_mutation has been removed; use frozen instead.

    2.0.0upgrade guide

  • The const property has been removed from Field.

    2.0.0upgrade guide

  • Field.final has been removed; use the typing.Final type hint instead.

    2.0.0upgrade guide

  • Field.max_items has been removed; use max_length instead.

    2.0.0upgrade guide

  • Field.min_items has been removed; use min_length instead.

    2.0.0upgrade guide

  • Field.regex has been removed; use pattern instead.

    2.0.0upgrade guide

  • The unique_items property has been removed from Field.

    2.0.0upgrade guide

  • The fields config setting has been removed; use Annotated on fields to modify them.

    2.0.0upgrade guide

  • Float values convert to integers only when their decimal part is zero, preventing loss of fractional data.

    2.0.0upgrade guide

  • Field constraints are no longer pushed down automatically to generic parameters; annotate the contained type with typing.Annotated instead.

    2.0.0upgrade guide

  • GenericModel has been removed; define generic BaseModel subclasses by adding Generic as a parent class.

    2.0.0upgrade guide

  • Custom types should replace __get_validators__ with __get_pydantic_core_schema__ to define validation using pydantic-core schemas.

    2.0.0upgrade guide

  • Custom types should replace __modify_schema__ with __get_pydantic_json_schema__ to customize JSON schema generation.

    2.0.0upgrade guide

  • The getter_dict config setting has been removed along with orm_mode.

    2.0.0upgrade guide

  • GetterDict has been removed along with orm_mode; it was an implementation detail of orm_mode.

    2.0.0upgrade guide

  • Pydantic no longer promises to preserve input types for generic collections; output types match annotations, while BaseModel subclasses and dataclasses retain their input types.

    2.0.0upgrade guide

  • Use the intent query parameter instead of goal when fetching pydantic.dev pages; describe what you're trying to achieve.

    2.0.0upgrade guide

  • The json_dumps config setting has been removed.

    2.0.0upgrade guide

  • The json_loads config setting has been removed.

    2.0.0upgrade guide

  • Generated schemas now indicate null for Optional fields, expose Decimal as a string, omit namedtuple preservation, and target draft 2020-12 by default.

    2.0.0upgrade guide

  • The config setting has been renamed to ignored_types.

    2.0.0upgrade guide

  • The config setting has been renamed to str_max_length.

    2.0.0upgrade guide

  • The config setting has been renamed to str_min_length.

    2.0.0upgrade guide

  • JSON serialization of non-string dictionary keys generally uses str(key), and model_dump_json output is compacted and may differ from json.dumps output.

    2.0.0upgrade guide

  • Use model_fields in place of the V1 __fields__ attribute.

    2.0.0upgrade guide

  • Use model_rebuild in place of update_forward_refs.

    2.0.0upgrade guide

  • model_validate_json provides the JSON-loading behavior previously available through parse_raw.

    2.0.0upgrade guide

  • model_validator replaces root_validator; in some cases, including assignment validation, it receives a model instance rather than a values dictionary.

    2.0.0upgrade guide

  • An Optional field without a default is required but allows None; Optional no longer implies a default of None.

    2.0.0upgrade guide

  • The config setting has been renamed to from_attributes.

    2.0.0upgrade guide

  • The parse_env_var classmethod was removed; customize settings sources to provide a parsing function.

    2.0.0upgrade guide

  • Pydantic dataclass __post_init__ now runs after validation rather than before.

    2.0.0upgrade guide

  • The post_init_call config setting has been removed.

    2.0.0upgrade guide

  • __post_init_post_parse__ has been removed because it became redundant after __post_init__ moved after validation.

    2.0.0upgrade guide

  • Pydantic dataclasses no longer expose __pydantic_model__ or rely on an underlying BaseModel; use TypeAdapter for related functionality.

    2.0.0upgrade guide

  • Use __pydantic_private__ in place of the V1 __private_attributes__ attribute.

    2.0.0upgrade guide

  • Use __pydantic_validator__ in place of the V1 __validators__ attribute.

    2.0.0upgrade guide

  • Color functionality moved to pydantic_extra_types.color.

    2.0.0upgrade guide

  • parse_file_as is removed from the public API.

    2.0.0upgrade guide

  • parse_raw_as is removed from the public API.

    2.0.0upgrade guide

  • PyObject was replaced by pydantic.ImportString.

    2.0.0upgrade guide

  • PaymentCardBrand moved to pydantic_extra_types.

    2.0.0upgrade guide

  • PaymentCardNumber moved to pydantic_extra_types.

    2.0.0upgrade guide

  • The alias generator moved to pydantic.alias_generators.to_pascal.

    2.0.0upgrade guide

  • The alias generator moved to pydantic.alias_generators.to_camel.

    2.0.0upgrade guide

  • version_info moved to pydantic.version.version_info.

    2.0.0upgrade guide

  • validate_model is removed from the public API.

    2.0.0upgrade guide

  • The deprecated root_validator can no longer run with skip_on_failure=False; set it explicitly to True.

    2.0.0upgrade guide

  • RootModel replaces the __root__ field for custom root models; RootModel types do not support arbitrary_types_allowed.

    2.0.0upgrade guide

  • The config setting has been renamed to json_schema_extra.

    2.0.0upgrade guide

  • The smart_union config setting has been removed; the default union_mode in V2 is 'smart'.

    2.0.0upgrade guide

  • Use the stack query parameter instead of organization to identify the language/framework context you are working in.

    2.0.0upgrade guide

  • Nested model serialization includes only fields defined on the field's annotated type, rather than all fields on a subclass instance, helping prevent accidental security bugs.

    2.0.0upgrade guide

  • A TypeError raised in a validator is no longer converted into a ValidationError, across all validation decorators.

    2.0.0upgrade guide

  • The underscore_attrs_are_private setting has been removed because V2 behaves as if it were always True in V1.

    2.0.0upgrade guide

  • Union validation preserves the input type when it matches a choice, rather than coercing it to an earlier choice; left-to-right behavior remains available with union_mode.

    2.0.0upgrade guide

  • Set union_mode to left_to_right to restore the non-short-circuiting left-to-right union behavior of V1.

    2.0.0upgrade guide

  • Validated URLs without a path now have a trailing slash, even when the input URL omitted one.

    2.0.0upgrade guide

  • The config setting has been renamed to validate_default.

    2.0.0upgrade guide

  • The decorator was renamed to validate_call; its former raw_function and validate attributes are not preserved.

    2.0.0upgrade guide

  • The validate_arguments decorator was renamed to validate_call; the old decorator's raw_function and validate attributes are not preserved.

    2.0.0upgrade guide

  • Validator function signatures can no longer include field or config arguments, even when using the deprecated validator decorator.

    2.0.0upgrade guide

Deprecations 16

  • Invalid after model validator function signatures now raise a deprecation warning instead of an error.

    2.12.3release notes

  • Defining a Config class in a BaseModel subclass is deprecated in favor of the model_config class attribute.

    2.0.0upgrade guide

  • from_orm is deprecated; use model_validate with from_attributes=True in the model config.

    2.0.0upgrade guide

  • The .json() method is deprecated; use model_dump_json instead, since arguments such as indent or ensure_ascii may produce confusing errors.

    2.0.0upgrade guide

  • Support for json_encoders in model config is deprecated; serialization decorators are preferred for common customization scenarios.

    2.0.0upgrade guide

  • The model construction method is now named model_construct; construct is retained as deprecated where possible.

    2.0.0upgrade guide

  • The model copy method is now named model_copy; copy is retained as deprecated where possible.

    2.0.0upgrade guide

  • The JSON schema method is now named model_json_schema; json_schema is retained as deprecated where possible.

    2.0.0upgrade guide

  • Using parameterized generics in isinstance checks is strongly discouraged; subclass the parameterized generic if such checks are needed.

    2.0.0upgrade guide

  • parse_file is deprecated; load the data and pass it to model_validate.

    2.0.0upgrade guide

  • parse_obj_as is deprecated; TypeAdapter is its complete replacement.

    2.0.0upgrade guide

  • parse_raw is deprecated; use model_validate_json for JSON input, or load the data and pass it to model_validate.

    2.0.0upgrade guide

  • Several V1 APIs, including parsing tools, encoders, and validators, are available under pydantic.deprecated paths.

    2.0.0upgrade guide

  • The root_validator decorator is deprecated; replace it with model_validator, whose allowed signatures differ.

    2.0.0upgrade guide

  • schema_of is deprecated; TypeAdapter is its complete replacement.

    2.0.0upgrade guide

  • The validator decorator is deprecated; replace it with field_validator.

    2.0.0upgrade guide

New APIs and options 17

  • Supports closed and extra_items via inheritance in TypedDict.

    2.14.1release notes

  • A counter core schema is added.

    2.14.0release notes

  • create_model() accepts a __namespace__ parameter.

    2.14.0release notes

  • The multiple_of constraint is supported in fraction and timedelta core schemas.

    2.14.0release notes

  • An ordered-dict core schema is added.

    2.14.0release notes

  • Adds a method to FieldInfo for returning its data as a dictionary.

    2.12.3release notes

  • The field_serializer decorator adds support for customizing serialization.

    2.0.0upgrade guide

  • Add the harness query parameter to identify the agent harness and model you are running.

    2.0.0upgrade guide

  • Configure models with a model_config class attribute containing the desired key/value pairs; the nested Config class approach is deprecated.

    2.0.0upgrade guide

  • The model dictionary serialization method is now named model_dump; dict is retained as deprecated where possible.

    2.0.0upgrade guide

  • Use model_dump_json in place of json for model JSON serialization.

    2.0.0upgrade guide

  • Use model_validate to validate objects, replacing parse_obj and, with from_attributes enabled, from_orm.

    2.0.0upgrade guide

  • ValidationError is available as pydantic.ValidationError.

    2.0.0upgrade guide

  • Pydantic V2 includes a mypy plugin that can be enabled in mypy configuration.

    2.0.0upgrade guide

  • The V2 package continues to expose the Pydantic V1 API through the pydantic.v1 namespace, allowing gradual migration.

    2.0.0upgrade guide

  • JSON schema generation methods accept schema_generator so callers can supply a custom GenerateJsonSchema subclass.

    2.0.0upgrade guide

  • The Field validate_default argument can reproduce the V1 always=True behavior while offering more flexibility and control.

    2.0.0upgrade guide

Performance 5

  • Serialization with per-index include or exclude on sequences no longer has quadratic time.

    2.14.3release notes

  • Skips decorator field checks when no field decorators exist.

    2.14.2release notes

  • Avoids heap allocation for small JSON model field buffers.

    2.14.2release notes

  • Avoids Python tuple allocation during model fields validation.

    2.14.1release notesrelease notes

  • Avoids an unnecessary extra dict allocation in model validation.

    2.14.1release notes

Behavior and default changes 5

  • Explicit by_alias now overrides validate_by_alias in validation JSON schemas.

    2.14.2release notes

  • Sequence serialization now supports named tuples.

    2.14.2release notes

  • Supports named tuples in Sequence validation.

    2.14.1release notes

  • Default factories for private attributes can now take validated model data.

    2.13.0release notes

  • Constructor arguments may be copied during validation and coercion, which is notable when passing mutable objects.

    2.0.0upgrade guide

Tooling 3

  • Wheels are now published for PyPy 8.0 using the pp80 ABI.

    2.14.2release notes

  • A beta code transformation tool is available to help migrate projects from Pydantic V1 to V2.

    2.0.0upgrade guide

  • When using V1 features, this plugin might also need to be enabled alongside the V2 mypy plugin.

    2.0.0upgrade guide

Fixes and other changes 45

  • Deeply nested data is no longer incorrectly reported as a cyclic reference.

    2.14.3release notes

  • Copying or unpickling models with defer_build no longer raises RecursionError.

    2.14.3release notes

  • Serialization JSON Schema now includes null for unless-none field serializers.

    2.14.3release notes

  • Wheels are now published for GraalPy 3.13 alongside 3.12, expanding the available platform builds.

    2.14.3release notes

  • Fixes unpickling of generic classes defined in a separate module.

    2.14.2release notes

  • Fixes a plugin crash on deferred empty models.

    2.14.2release notes

  • Calls repr of values lazily during nested union serialization.

    2.14.2release notes

  • Fixes forward annotation evaluation and type variable substitution when rebuilding parametrized generic models.

    2.14.2release notes

  • Fixes pickling of PydanticCustomError and ValidationError instances containing custom errors.

    2.14.2release notes

  • Prevents infinite recursion when validating an invalid default.

    2.14.2release notes

  • Fixes Self resolution in parametrized generics.

    2.14.2release notes

  • Fixes deep copying of self-referential models.

    2.14.2release notes

  • URL types equality now takes preserve_empty_path into account.

    2.14.2release notes

  • Adds a recursion guard to validate_strings().

    2.14.2release notes

  • Fixes the arguments-v3 schema when variadic keywords are present.

    2.14.1release notes

  • The Python Decimal validator now enforces the max_digits whole-digits limit.

    2.14.1release notes

  • Fixes a TypeError involving ForwardRef on Python 3.10.0.

    2.14.1release notes

  • OverflowError is caught during ByteSize validation.

    2.14.0release notes

  • Exceptions are handled during Decimal validation.

    2.14.0release notes

  • init and kw_only=False are propagated from Field() to stdlib dataclass fields.

    2.14.0release notes

  • Config propagation for stdlib dataclasses and TypedDicts in JSON Schema is fixed.

    2.14.0release notes

  • Propagated extra config is respected in the JSON Schema of stdlib dataclasses.

    2.14.0release notes

  • The model_config attribute is no longer mutated.

    2.14.0release notes

  • URL prefixes are no longer validated multiple times in multi host URLs.

    2.14.0release notes

  • Python 3.15 is now supported.

    2.14.0release notes

  • Incomplete types are rebuilt during serialization inference.

    2.14.0release notes

  • OS errors are handled during ZoneInfo validation.

    2.14.0release notes

  • Validated model fields are counted once in smart unions.

    2.13.5release notes

  • Validators can now be reused when plugins are set.

    2.13.5release notes

  • Preserves RootModel core metadata.

    2.13.4release notes

  • Handles AttributeError subclasses when using from_attributes.

    2.13.3release notes

  • Fixes ValidationInfo.field_name being missing when using model_validate_json().

    2.13.2release notes

  • ValidationInfo.data is no longer missing when using model_validate_json().

    2.13.1release notes

  • Model equality is fixed when using runtime extra configuration.

    2.13.0release notes

  • Serialization warns when fixed length tuples have too few items.

    2.13.0release notes

  • The synthesized BaseSettings.__init__() signature uses a changed type for Any in _build_sources.

    2.13.0release notes

  • The namespace is updated to version 1.10.26, which includes support for Python 3.14.

    2.13.0release notes

  • Fixed a pickle error when using model_construct on a model with MISSING as a default value.

    2.12.5release notes

  • Reverts URL credential percent-encoding in the build() method of AnyUrl and Dsn types.

    2.12.4release notes

  • Validation no longer gets default values from defaultdict, fixing a subtle regression in its validation behavior.

    2.12.4release notes

  • Fields with exclude_if are no longer included among JSON Schema required fields.

    2.12.4release notes

  • Fixes field serializers on nested typed dictionaries.

    2.12.4release notes

  • Adds type inference for IP address types, fixing their JSON serialization when serialize_as_any is used.

    2.12.4release notes

  • Fixes forward references in parent TypedDict classes on Python 3.14 and greater.

    2.12.4release notes

  • Mutations on FieldInfo classes reused as Annotated metadata are supported again, though this remains an unsupported pattern.

    2.12.3release notes

pydantic 19 changes

Breaking changes 3

  • Only accepts . as the decimal separator, addressing a security advisory.

    1.10.27release notes

  • V1 support, including the pydantic.v1 namespace in Pydantic V2, fully ends after this release.

    1.10.27release notes

  • With ag-ui-protocol 1.0 or later, binary input parts are converted to image, audio, video, or document content; parts without a MIME type or payload still raise.

    1.0.0docs

Security 2

  • Dataclasses ignore internal __pydantic attributes when setting extra values, addressing a security advisory.

    1.10.27release notes

  • Checks unique_items in linear time for builtin scalar types, addressing a security advisory.

    1.10.27release notes

Behavior and default changes 1

  • Unsupported message roles, input content types, or media source types introduced by a newer protocol version are skipped with a warning instead of failing the whole request.

    1.0.0docs

Fixes and other changes 3