Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Data validation using Python type hints.
Fast and extensible, Pydantic plays nicely with your linters/IDE/brain. Define how data should be in pure, canonical Python 3.8+; validate it with Pydantic.
We've started a company based on the principles that I believe have led to Pydantic's success. Learn more from the Company Announcement.
Pydantic V2 is a ground-up rewrite that offers many new features, performance improvements, and some breaking changes compared to Pydantic V1.
If you're using Pydantic V1 you may want to look at the
pydantic V1.10 Documentation or,
1.10.X-fixes
git branch. Pydantic V2 also ships with the latest version of Pydantic V1 built in so that you can incrementally upgrade your code base and projects: from pydantic import v1 as pydantic_v1
.
See documentation for more details.
Install using pip install -U pydantic
or conda install pydantic -c conda-forge
.
For more installation options to make Pydantic even faster,
see the Install section in the documentation.
from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel
class User(BaseModel):
id: int
name: str = 'John Doe'
signup_ts: Optional[datetime] = None
friends: List[int] = []
external_data = {'id': '123', 'signup_ts': '2017-06-01 12:22', 'friends': [1, '2', b'3']}
user = User(**external_data)
print(user)
#> User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3]
print(user.id)
#> 123
For guidance on setting up a development environment and how to make a contribution to Pydantic, see Contributing to Pydantic.
See our security policy.
Callable
discriminators by @sydney-runkle in #10400PlainValidator
by @Viicos in #10427Union
serialization warnings by @sydney-runkle in pydantic/pydantic-core#1449_IncEx
type alias, only allow True
by @Viicos in #10414ZoneInfo
validation with various invalid types by @sydney-runkle in #10408annotated-types
bound to >=0.6.0
by @sydney-runkle in #10327tzdata
install requirement into optional timezone
dependency by @jakob-keller in #10331IncExc
type alias definition by @Viicos in #10339The code released in v2.9.0 is practically identical to that of v2.9.0b2.
ruff
to v0.5.0
and pyright
to v1.1.369
by @sydney-runkle in #9801pydantic-extra-types
to v2.9.0
by @sydney-runkle in #9832pdm v2.18.1
by @Viicos in #10138v1
version stub to v1.10.18
by @sydney-runkle in #10214pydantic-core
to v2.23.2
by @sydney-runkle in #10311ZoneInfo
by @Youssefares in #9896Config.val_json_bytes
by @josh-newman in #9770complex
number by @changhc in #9654annotated_types.Not
by @aditkumar72 in #10210WithJsonSchema
to inject $ref
s w/ http
or https
links by @dAIsySHEng1 in #9863PathLike
types by @nix010 in #9764str
or callable
discriminators to select the correct serializer by @sydney-runkle in in pydantic/pydantic-core#1397dict
type json_schema_extra
by @sydney-runkle in #9792
pattern
for incompatible types by @sydney-runkle in #10158'allOf'
JSON schema workarounds by @dpeachey in #10029typed_dict_cls
data from CoreMetadata
by @sydney-runkle in #10180Examples
class by @Viicos in #10181initial_metadata
from internal metadata construct by @sydney-runkle in #10194re.Pattern.search
instead of re.Pattern.match
for consistency with rust
behavior by @tinez in pydantic/pydantic-core#1368pydantic-core
serialization warning by @BoxyUwU in pydantic/pydantic-core#1377pydantic-core
, change metadata
type hint in core schemas from Any
-> Dict[str, Any] | None
by @sydney-runkle in pydantic/pydantic-core#1411self
isn't returned from model validator by @sydney-runkle in #10255BaseModel
by @sydney-runkle in #10013multiple_of_validator()
by 31% in pydantic/_internal/_validators.py
by @misrasaurabh1 in #9839ModelPrivateAttr.__set_name__()
by 18% in pydantic/fields.py
by @misrasaurabh1 in #9841dataclass()
by 7% in pydantic/dataclasses.py
by @misrasaurabh1 in #9843_field_name_for_signature
by 37% in pydantic/_internal/_signature.py
by @misrasaurabh1 in #9951GenerateSchema._unpack_refs_defs
by 26% in pydantic/_internal/_generate_schema.py
by @misrasaurabh1 in #9949apply_each_item_validators
by 100% in pydantic/_internal/_generate_schema.py
by @misrasaurabh1 in #9950ConfigWrapper.core_config
by 28% in pydantic/_internal/_config.py
by @misrasaurabh1 in #9953use_enum_values
on Literal
types by @kwint in #9787BaseModel/RootModel
inheritance by @dmontagu in #9913str
type annotation with Any
in validator factories in documentation on validators by @maximilianfellhuber in #9885ComputedFieldInfo.wrapped_property
pointer when a property setter is assigned by @tlambert03 in #9892main.IncEnx
by @tlambert03 in #9924type[Annotated[...]]
by @Viicos in #9932mypy
plugin: handle frozen fields on a per-field basis by @dmontagu in #9935invalid-annotated-type
error code by @sydney-runkle in #9948uuid
, url
, and ip
types by @sydney-runkle in #9975date
schemas to _generate_schema.py
by @sydney-runkle in #9976decimal.Decimal
validation to _generate_schema.py
by @sydney-runkle in #9977_std_types_schema.py
by @sydney-runkle in #9959GenerateSchema.match_type
options by @sydney-runkle in #9961dataclass
ignoring default_factory
passed in Annotated by @kc0506 in #9971Sequence
ignoring discriminator
by @kc0506 in #9980IPvAnyAddress
and IPvAnyInterface
by @haoyun in #9990mypy
plugin for from_orm
check requiring from_attributes=True config by @radekwlsk in #9938strict=True
to __init__
in mypy
plugin by @kc0506 in #9998deque
annotations by @sydney-runkle in #10018__pydantic_extra__
annotation in specific circumstances by @Viicos in #10070frozen
enforcement for dataclasses
by @sydney-runkle in #10066__get_pydantic_core_schema__
signature by @Viicos in #10075is_annotated
consistently by @Viicos in #10095PydanticDeprecatedSince26
typo by @kc0506 in #10101pyright
tests, refactor model decorators signatures by @Viicos in #10092ip
serialization logic by @sydney-runkle in #10112dataclasses
by @mochi22 in #10082when_used
set to 'json-unless-none'
and the default value is None
by @Viicos in #10121ImportString
special cases by @sydney-runkle in #10137__
prefixed annotations by @sydney-runkle in #10136nullable
schemas with serialization
schema available during JSON Schema generation by @Viicos in #10132BaseModel
annotations by @kc0506 in #10110PrivateAttr
with Annotated
by @Viicos in #10157number
type for literal and enum schemas by @Viicos in #10172Mapping
and MutableMapping
annotations to use mapping schema instead of dict schema by @sydney-runkle in #10020field_serializer
with computed field when using *
by @nix010 in pydantic/pydantic-core#1349Union
serializer before inference by @sydney-runkle in pydantic/pydantic-core#1398float
serialization behavior in strict
mode by @sydney-runkle in pydantic/pydantic-core#1400exactness
into Decimal validation logic to improve union validation behavior by @sydney-runkle in in pydantic/pydantic-core#1405pytest.warns()
by @mgorny in #10241ModelMetaclass
by @Viicos in #10242__init__
by @Viicos in #10264BigInt
serialization for int
subclasses by @kxx317 in pydantic/pydantic-core#1417info
by @sydney-runkle in #10277__pydantic_complete__
is set when rebuilding dataclasses
by @Viicos in #10291schema_generator
config value in TypeAdapter
by @sydney-runkle in #10300pydantic
pydantic-core
Pre-release, see the GitHub release for details.
Pre-release, see the GitHub release for details.
ruff
to v0.5.0
and pyright
to v1.1.369
by @sydney-runkle in #9801pydantic-core
to v2.20.1
, pydantic-extra-types
to v2.9.0
by @sydney-runkle in #9832to_snake
from v2.7 -> v2.8 by @sydney-runkle in #9812The code released in v2.8.0 is functionally identical to that of v2.8.0b1.
v1.1.367
and add type checking tests for pipeline API by @adriangb in #9674pydantic.v1
stub to v1.10.17
by @sydney-runkle in #9707v2.8.0b1
by @sydney-runkle in #9741pydantic-core
to v2.20.0
by @sydney-runkle in #9745pdm
version used for pdm.lock
to v2.16.1 by @sydney-runkle in #9761ruff
v0.4.8
by @Viicos in #9585defer_build
for TypeAdapter
by @MarkusSintonen in #8939deprecated
field in json schema by @NeevCohen in #9298fail_fast
feature by @uriyyo in #9708ser_json_inf_nan='strings'
mode to produce valid JSON by @josh-newman in pydantic/pydantic-core#1307Annotated
field by @nix010 in #9170__validators__
values in create_model
by @sydney-runkle in #9697smart
union matching logic by @sydney-runkle in pydantic/pydantic-core#1322
You can read more about our smart
union matching logic here. In some cases, if the old behavior
is desired, you can switch to left-to-right
mode and change the order of your Union
members._display_error_loc()
by 25% in pydantic/v1/error_wrappers.py
by @misrasaurabh1 in #9653_get_all_json_refs()
by 34% in pydantic/json_schema.py
by @misrasaurabh1 in #9650is_pydantic_dataclass()
by 41% in pydantic/dataclasses.py
by @misrasaurabh1 in #9652to_snake()
by 27% in pydantic/alias_generators.py
by @misrasaurabh1 in #9747unwrap_wrapped_function()
by 93% in pydantic/_internal/_decorators.py
by @misrasaurabh1 in #9727__spec__.parent
with __package__
by @hramezani in #9331Sequence
type by @anesmemisevic in #9303_frame_depth
by @Viicos in #9353ImportString
json schema compatible by @amitschang in #9344PrivateAttr
) from __init__
signature in type checkers by @idan22moral in #9293TypeVar
defaults robust to the CPython PEP-696
implementation by @AlexWaygood in #9426PlainSerializer
with builtin types by @Viicos in #9450strict
specification for StringConstraint(strict=False)
by @vbmendes in #9476Self
where possible by @Viicos in #9479RootModel.model_construct
signature in the mypy
plugin by @Viicos in #9480validation_context
by @OhioDschungel6 in #9508dump_json
/dump_python
by @alexcouper in #9495Field()
constructor by @bjmc in #9484TypeAdapter
by @Viicos in #9570__setstate__
of BaseModel by @anhpham1509 in #9584PEP 746
by @adriangb in #9587TypeVar
fields by @dmontagu in #9606regex
flags in validation and json schema by @sydney-runkle in #9591IpvAnyAddress
by @sydney-runkle in #9640__pydantic_extra__
by @dmontagu in #9659Optional[Decimal]
by @lazyhope in #9754validate_call
type params fix by @sydney-runkle in #9760re.Pattern
object in regex patterns to allow for regex flags by @sydney-runkle in pydantic/pydantic-core#1318Pre-release, see the GitHub release for details.
pydantic.v1
to v1.10.16
reference by @sydney-runkle in #9639pydantic-core
to v2.18.4
by @sydney-runkle in #9550pydantic-core
to v2.18.3
by @sydney-runkle in #9515__spec__.parent
with __package__
by @hramezani in #9331int
s with leading unary minus by @RajatRajdeep in pydantic/pydantic-core#1291str
subclass validation for enums by @sydney-runkle in pydantic/pydantic-core#1273BigInt
s in Literal
s and Enum
s by @samuelcolvin in pydantic/pydantic-core#1297str
subclass as input by @davidhewitt in pydantic/pydantic-core#1296pydantic-core
to v2.18.2
by @sydney-runkle in #9307…
by @LouisGobert in #9214validation_alias
behavior with model_construct
for AliasChoices
and AliasPath
by @sydney-runkle in #9223typing.Literal
and import it outside the TYPE_CHECKING block by @frost-nzcr4 in #9232Secret
serialization schema, applicable for unions by @sydney-runkle in #9240strict
application to function-after
with use_enum_values
by @sydney-runkle in #9279model_construct
on a class which defines model_post_init
fails with AttributeError
by @babygrimes in #9168model_json_schema
with config types by @NeevCohen in #9287int
by @samuelcolvin in pydantic/pydantic-core#1269int
s with leading unary plus by @cknv in pydantic/pydantic-core#1272extra != 'ignore'
and from_attributes=True
by @davidhewitt in pydantic/pydantic-core#1276Enum
's missing
function as ValidationError
by @sydney-runkle in pydantic/pydantic-core#1274Iterable
validation by @davidhewitt in pydantic/pydantic-core#1271The code released in v2.7.0 is practically identical to that of v2.7.0b1.
pyproject.toml
sections by @Viicos in #8899pydantic-core
to v2.18.1
by @sydney-runkle in #9211jiter
v0.2.0
by @samuelcolvin in pydantic/pydantic-core#1250FieldInfo.description
by @Viicos in #6563with_config
decorator to comply with typing spec by @Viicos in #8611ByteSize.human_readable
by @jks15satoshi in #8706Secret
base type by @conradogarciaberrotaran in #8519Sphinx
inventories for cross references in docs by @Viicos in #8682deprecated
fields by @Viicos in #8237field_serializer('*')
by @ornariece in #9001model_config
is defined as a model property by @alexeyt101 in #9004create_model()
to support typing.Annotated
as input by @wannieman98 in #8947ClickhouseDsn
support by @solidguy7 in #9062re.Pattern[str]
to pattern
field by @jag-k in #9053serialize_as_any
runtime setting by @sydney-runkle in #8830typing.Self
by @Youssefares in #9023context
to serialization by @ornariece in #8965Finalized in v2.7.0, rather than v2.7.0b1:
warnings
parameter for serialization utilities to allow raising a warning by @Lance-Drane in #9166model_construct
behavior with extra
by @sydney-runkle in #8807RootModel
subclasses by @sydney-runkle in #8857PEP570
syntax by @Viicos in #8940enum
and type
to the JSON schema for single item literals by @dmontagu in #8944update_json_schema
internal function by @sydney-runkle in #9125enum
validator improvements by @samuelcolvin in #9045enum
validation and serialization to Rust by @samuelcolvin in #9064aarch64
(Note: SIMD on x86 will be implemented in a future release) by @samuelcolvin in in pydantic/jiter#65Cow<str>
from jiter
by @davidhewitt in pydantic/pydantic-core#1231Sequence
s by @sydney-runkle in #8614__qualname__
by @anci3ntr0ck in #8642__pydantic_extra__
annotation being a string or inherited by @alexmojaki in #8659NameEmail
by @Holi0317 in #8650BaseModel
by @bluenote10 in #8651mypy
plugin and no_strict_optional = True
by @dmontagu in #8666ByteSize
error type
change by @sydney-runkle in #8681__pydantic_config__
ignored for TypeDict by @13sin in #8734pytest v8.0.0
due to pytest.warns()
starting to work inside pytest.raises()
by @mgorny in #8678is_valid_field
from 1.x for mypy
plugin by @DanielNoord in #8738mypy
strict equality flag by @dmontagu in #8799FieldInfo.__repr_args__
by @sydney-runkle in #8801BaseModel
type annotations to be resolvable by typing.get_type_hints
by @devmonkey22 in #7680AliasGenerator
by @sydney-runkle in #8810date
-> datetime
timezone assumption fix by @sydney-runkle in #8823ast.Str
by @Viicos in #8837deprecated
decorators by @Viicos in #8877NameEmail
if name includes an email address by @NeevCohen in #8860TypeAdapter
's typing compatible with special forms by @adriangb in #8923enum
s by @dmontagu in #8920model_json_schema
usage by @sydney-runkle in #8928mypy
plugin by @dmontagu in #9008PlainSerializer
usage with std type constructor by @sydney-runkle in #9031Model.__getattr__()
by @NeevCohen in #9082ClassVar
forward ref inherited from parent class by @alexmojaki in #9097True
by @andresliszt in #8977deque
when passed to Sequence[blah blah blah]
by @sydney-runkle in #9128model_post_init
by @Viicos in #9134model_construct
with validation_alias
by @ornariece in #9144Literal
null
types by @bruno-f-cruz in #9135Pre-release, see the GitHub release for details.
AliasGenerator
with computed_field
decorator by @sydney-runkle in #8806pydantic-settings
version in the docs by @hramezani in #8906pydantic-core
2.16.3 by @sydney-runkle in #8879pydantic-core
2.16.2 by @sydney-runkle in #8717mypy
plugin and no_strict_optional = True
by @dmontagu in #8666ByteSize
error type
change by @sydney-runkle in #8681Field
annotations in dataclasses by @sydney-runkle in #8679PlainValidator
by @sydney-runkle in #8710Union
by @davidhewitt in pydantic/pydantic-core#1174computed_field
JSON serializer exclude_none
behavior by @sydney-runkle in pydantic/pydantic-core#1187The code released in v2.6.0 is practically identical to that of v2.6.0b1.
email-validator
version >= 2.0 by @commonism in #6033pydantic-extra-types==2.4.1
by @yezz123 in #8478pyright==1.1.345
by @Viicos in #8453NatsDsn
by @ekeew in #6874ConfigDict.ser_json_inf_nan
by @davidhewitt in #8159types.OnErrorOmit
by @adriangb in #8222AliasGenerator
usage by @sydney-runkle in #8282yyyy-MM-DD
datetime parsing by @sydney-runkle in #8404ByteSize
class #8415 by @luca-matei in #8507ByteSize
by @geospackle in #8537eval_type_backport
to handle union operator and builtin generic subscripting in older Pythons by @alexmojaki in #8209dataclass
fields init
by @dmontagu in #8552ValidationError
by @davidhewitt in pydantic/pydantic-core#1119self
in BaseModel
constructor, so no field name can ever conflict with it by @ariebovenberg in #8072@validate_call
return a function instead of a custom descriptor - fixes binding issue with inheritance and adds self/cls
argument to validation errors by @alexmojaki in #8268BaseModel
docstring from JSON schema description by @sydney-runkle in #8352classproperty
decorator for model_computed_fields
by @Jocelyn-Gas in #8437int
extraction by @samuelcolvin in pydantic/pydantic-core#1155dataclass
serialization speedups by @samuelcolvin in pydantic/pydantic-core#1162HashMap
creation when looking up small JSON objects in LazyIndexMaps
by @samuelcolvin in pydantic/jiter#55Peak
with more efficient Peek
by @davidhewitt in pydantic/jiter#48getattr
warning in deprecated BaseConfig
by @tlambert03 in #7183model_fields
, not whole __dict__
by @alexmojaki in #7786mypy
plugin by @dmontagu in #7411mypy
error on untyped ClassVar
by @vincent-hachin-wmx in #8138BaseModel.__eq__
instead of whole __dict__
by @QuentinSoubeyranAqemia in #7825strict
docstring in model_validate
method. by @LukeTonin in #8223computed_field
by @Viicos in #8227validate_call
decorator to be dynamically assigned to a class method by @jusexton in #8249unittest.mock
deprecation warnings by @ibleedicare in #8262JsonValue
contains subclassed primitive values by @jusexton in #8286mypy
error on free before validator (classmethod) by @sydney-runkle in #8285to_snake
conversion by @jevins09 in #8316ModelMetaclass.__prepare__
by @slanzmich in #8305config
specification when initializing a TypeAdapter
when the annotated type has config already by @sydney-runkle in #8365alias
in dataclass
signature by @NeevCohen in #8387Field(...)
in a forward ref by @dmontagu in #8494__dict__
with model_construct
call by @sydney-runkle in #8500path_type
creation when globals does not contain __name__
by @hramezani in #8470from __future__ import annotations
by @sydney-runkle in #8513@deprecated
by @Viicos in #8294model_construct
call by @sydney-runkle in #8525TypeAliasType
for types with refs by @dmontagu in #8526pydantic.Field(repr=False)
in dataclasses by @tigeryy2 in #8511dataclass_transform
behavior for RootModel
by @Viicos in #8163exclude_none
for json serialization of computed_field
s by @sydney-runkle in pydantic/pydantic-core#1098pydantic
pydantic-core
Pre-release, see the GitHub release for details.
pydantic-core
to 2.14.6pydantic-core
to 2.14.5ConfigDict.ser_json_inf_nan
by @davidhewitt in #8159Literal
from JSON keys when used as dict
key by @sydney-runkle in pydantic/pydantic-core#1075custom_init
on members of Union
by @sydney-runkle in pydantic/pydantic-core#1076JsonValue
bool
serialization by @sydney-runkle in #8190Literal
in Union
s by @sydney-runkle in pydantic/pydantic-core#1089ValidateCallWrapper
error when creating a model which has a @validate_call wrapped field annotation by @sydney-runkle in #8110The code released in v2.5.0 is functionally identical to that of v2.5.0b1.
pyright==1.1.335
by @Viicos in #8075ValidationError
errors by @adriangb in #7806__doc__
argument in create_model()
by @chris-spann in #7863regex_engine
flag - meaning you can use with the Rust or Python regex libraries in constraints by @utkini in #7768ComputedFieldInfo
by @alexmojaki in #7889ruff
formatter by @Luca-Blight in #7930validation_error_cause
to config by @zakstucke in #7626CallableDiscriminator
and Tag
by @dmontagu in #7983
examples
and json_schema_extra
to @computed_field
by @alexmojaki in #8013JsonValue
type by @dmontagu in #7998str
as argument to Discriminator
by @dmontagu in #8047SchemaSerializer.__reduce__
method to enable pickle serialization by @edoakes in pydantic/pydantic-core#1006ultra_strict
with new smart union implementation, the way unions are validated has changed significantly to improve performance and correctness, we have worked hard to absolutely minimise the number of cases where behaviour has changed, see the PR for details - by @davidhewitt in pydantic/pydantic-core#867extra='allow'
by @sydney-runkle in #7683Enum
types with no cases by @sydney-runkle in #7927Generic
before BaseModel
by @alexmojaki in #7891jiter
by @samuelcolvin in pydantic/pydantic-core#974__getattr__
for all package imports, improve import time by @samuelcolvin in #7947mypy
issue with subclasses of RootModel
by @sydney-runkle in #7677FieldInfo
when a forward ref gets evaluated by @dmontagu in #7698SecretStr
from JSON (regression in v2.4) by @sydney-runkle in #7729defer_build
behavior with TypeAdapter
by @sydney-runkle in #7736mypy
versions by @dmontagu in #7742TypeVar
handling when default is not set by @pmmmwh in #7719strict
on Enum
type fields by @sydney-runkle in #7761weakref.ref
instead of subclassing to fix cloudpickle
serialization by @edoakes in #7780model_post_init
in subclasses by @alexmojaki in #7775json_schema_extra
by @alexmojaki in #7803strict
specification for UUID
types by @sydney-runkle in #7865pydantic.Field(kw_only=True)
with inherited dataclasses by @PrettyWood in #7827validate_call
decorator for methods in classes with __slots__
by @sydney-runkle in #7883dataclasses.field
default by @hramezani in #7898importlib_metadata
on python 3.7 by @sydney-runkle in #7904|
operator (Union) in PydanticRecursiveRef by @alexmojaki in #7892display_as_type
for TypeAliasType
in python 3.12 by @dmontagu in #7929NotRequired
generics in TypedDict
by @sydney-runkle in #7932TypeAliasType
specifications produce different schema definitions by @alexdrydew in #7893PrivateAttr
is passed from Annotated
default position by @tabassco in #8004classmethod
instead of classmethod[Any, Any, Any]
by @Mr-Pepe in #7979Optional
field with validate_default
only performing one field validation by @sydney-runkle in pydantic/pydantic-core#1002definition-ref
bug with Dict
keys by @sydney-runkle in pydantic/pydantic-core#1014bool
types with coerce_numbers_to_str=True
by @sydney-runkle in pydantic/pydantic-core#1017NaN
in float and decimal constraints by @davidhewitt in pydantic/pydantic-core#1037lax_str
and lax_int
support for enum values not inherited from str/int by @michaelhly in pydantic/pydantic-core#1015Union
of List
types by @sydney-runkle in pydantic/pydantic-core#1039max_digits
and decimals
to pass if normalized or non-normalized input is valid by @sydney-runkle in pydantic/pydantic-core#1049ValidationError
messages by @Iipin in pydantic/pydantic-core#1050'-'
as datetime
input by @davidhewitt in pydantic/speedate#52 & pydantic/pydantic-core#1060pydantic
pydantic-core
Pre-release, see the GitHub release for details.
models_json_schema
for generic models by @adriangb in #7654Any
by @adriangb in #7606Base64Url
types by @dmontagu in #7286number
to str
coercion by @lig in #7508field_name
and data
in all validators if there is data and a field name by @samuelcolvin in #7542BaseModel.model_validate_strings
and TypeAdapter.validate_strings
by @hramezani in #7552plugins
experimental implementation by @lig @samuelcolvin and @Kludex in #6820model_post_init
in subclass with private attrs by @Viicos in #7302Extra
as deprecated by @disrupted in #7299EncodedStr
a dataclass by @Kludex in #7396annotated_handlers
to be public by @samuelcolvin in #7569CoreSchema
by @adriangb in #7523CoreSchema
walking by @adriangb in #7528dict.get
and dict.setdefault
with more verbose versions in CoreSchema
building hot paths by @adriangb in #7536CoreSchema
discovery by @adriangb in #7535CoreSchema
validation for faster startup times by @adriangb in #7565TypedDict
from grandparent classes by @dmontagu in #7272strict
config overridable in field for Path by @hramezani in #7281ser_json_<timedelta|bytes>
on default in GenerateJsonSchema
by @Kludex in #7269SkipValidation
to referenced schemas by @adriangb in #7381__get_pydantic_core_schema__
signature by @hramezani in #7415TypeAdapter
) by @sydney-runkle in #7435TypeError
on model_validator
in wrap
mode by @pmmmwh in #7496repr
work for instances that failed initialization when handling ValidationError
s by @dmontagu in #7439UUID
values having UUID.version=None
by @lig in #7566__iter__
returning private cached_property
info by @sydney-runkle in #7570Field(..., exclude: bool)
docs by @samuelcolvin in #7214Base64Str
and Base64Bytes
by @Kludex in #7192config.defer_build
for serialization first cases by @samuelcolvin in #7024validators.md
to correct validate_default
kwarg by @lmmx in #7229tzinfo.fromutc
method for TzInfo
in pydantic-core
by @lig in #7019__get_validators__
by @hramezani in #7197xfail
ing test for root model extra stop xfail
ing by @dmontagu in #6937Field.include
by @hramezani in #6852Path
fields by @samuelcolvin in #6903ForwardRef
wrapper for py 3.10.0 (shim until bpo-45166) by @randomir in #6919main
branch for badge links by @Viicos in #6925ser_json_bytes
regarding base64 encoding by @Viicos in #7052@validate_call
to work on async methods by @adriangb in #7046Settings
and SettingsConfigDict
by @JeanArhancet in #7002short_version
and use it in links by @hramezani in #7115RootModel
by @Kludex in #7113Field.exclude
by @Viicos in #7086validate_assignment
to use Field.frozen
by @Viicos in #7103_core_utils
by @samuelcolvin in #7040round_trip
in Json type documentation by @jc-louis in #7137StringConstraints
for use as Annotated metadata by @adriangb in #6605help(BaseModelSubclass)
raises errors by @hramezani in #6758@model_validator(mode="after")
by @ljodal in #6753contentSchema
keyword for JSON schema by @dmontagu in #6715version_info()
by @samuelcolvin in #6785SkipJsonSchema
annotation by @Kludex in #6653GenericModel
to MOVED_IN_V2
by @adriangb in #6776docs/usage/types/custom.md
by @hramezani in #6803float
-> Decimal
coercion precision loss by @adriangb in #6810annotated_types.MaxLen
validator for custom sequence types by @ImogenBits in #6809InstanceOf
by @dmontagu in #6829json_encoders
by @adriangb in #6811WeakValueDictionary
to fix generic memory leak by @dmontagu in #6681config.defer_build
to optionally make model building lazy by @samuelcolvin in #6823UUID
serialization to pydantic-core by @davidhewitt in #6850json_encoders
docs by @adriangb in #6848staticmethod
/classmethod
order with validate_call by @dmontagu in #6686Config
by @samuelcolvin in #6847Field.exclude
takes priority over call-time include/exclude
by @hramezani in #6851GenerateSchema
public by @adriangb in #6737Field.alias
behavior in Pydantic V2 by @hramezani in #6508alias_priority
by @tpdorsey in #6520pydantic-core
to v2.2.0 by @lig in #6589enum
error type docs by @lig in #6603max_length
for unicode strings by @lig in #6559pydantic.v1
by @tpdorsey in #6604$ref
as an alias by @dmontagu in #6568AnyUrl
etc by @davidhewitt in #6618json_schema_extra
on RootModel
using Field
by @lig in #6622transform
docstring by @StefanBRas in #6649RootModel
would change the value of __dict__
, #6457 by @dmontaguconstr
documentation, renamed old regex
to new pattern
, #6452 by @miiliGenerateJsonSchema.generate_definitions
signature, #6436 by @dmontaguSee the full changelog here
First patch release of Pydantic V2
setattr
(i.e. m.some_extra_field = 'extra_value'
)
are added to .model_extra
if model_config
extra='allowed'
. Fixed #6333, #6365 by @aaraneySee the full changelog here
Pydantic V2 is here! :tada:
See this post for more details.
Third beta pre-release of Pydantic V2
See the full changelog here
Add from_attributes
runtime flag to TypeAdapter.validate_python
and BaseModel.model_validate
.
See the full changelog here
First beta pre-release of Pydantic V2
See the full changelog here
Fourth pre-release of Pydantic V2
See the full changelog here
Third pre-release of Pydantic V2
See the full changelog here
Second pre-release of Pydantic V2
See the full changelog here
First pre-release of Pydantic V2!
See this post for more details.
... see here for earlier changes.
FAQs
Data validation using Python type hints
We found that pydantic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.