Package: pydantic
PydanticData 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.Pydantic Company :rocket:We've started a company based on the principles that I believe have led to Pydantic's success.
Learning more from theCompany Announcement.Pydantic V1.10 vs. V2Pydantic 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 thepydantic V1.10 Documentationor,1.10.X-fixesgit 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.HelpSeedocumentationfor more details.InstallationInstall usingpip install -U pydanticorconda install pydantic -c conda-forge.
For more installation options to make Pydantic even faster,
see theInstallsection in the documentation.A Simple ExamplefromdatetimeimportdatetimefromtypingimportList,OptionalfrompydanticimportBaseModelclassUser(BaseModel):id:intname:str='John Doe'signup_ts:Optional[datetime]=Nonefriends: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)#> 123ContributingFor guidance on setting up a development environment and how to make a
contribution to Pydantic, seeContributing to Pydantic.Reporting a Security VulnerabilitySee oursecurity policy.Changelogv2.6.3 (2024-02-27)GitHub releaseWhat's ChangedPackagingUpdatepydantic-settingsversion in the docs by@hramezaniin#8906FixesFix discriminated union schema gen bug by@sydney-runklein#8904v2.6.2 (2024-02-23)GitHub releaseWhat's ChangedPackagingUpgrade topydantic-core2.16.3 by@sydney-runklein#8879Fixes'YYYY-MM-DD' date string coerced to datetime shouldn't infer timezone by@sydney-runkleinpydantic/pydantic-core#1193v2.6.1 (2024-02-05)GitHub releaseWhat's ChangedPackagingUpgrade topydantic-core2.16.2 by@sydney-runklein#8717FixesFix bug withmypyplugin andno_strict_optional = Trueby@dmontaguin#8666FixByteSizeerrortypechange by@sydney-runklein#8681Fix inheritingFieldannotations in dataclasses by@sydney-runklein#8679Fix regression in core schema generation for indirect definition references by@dmontaguin#8702Fix unsupported types bug withPlainValidatorby@sydney-runklein#8710Reverting problematic fix from 2.6 release, fixing schema building bug by@sydney-runklein#8718Fix warning for tuple of wrong size inUnionby@davidhewittinpydantic/pydantic-core#1174Fixcomputed_fieldJSON serializerexclude_nonebehavior by@sydney-runkleinpydantic/pydantic-core#1187v2.6.0 (2024-01-29)GitHub releaseThe code released in v2.6.0 is practically identical to that of v2.6.0b1.What's ChangedPackagingCheck foremail-validatorversion >= 2.0 by@commonismin#6033Upgrade `ruff`` target version to Python 3.8 by@Elkiwain#8341Update topydantic-extra-types==2.4.1by@yezz123in#8478Update topyright==1.1.345by@Viicosin#8453Update pydantic-core from 2.14.6 to 2.16.1, significant changes from these updates are described below, full changeloghereNew FeaturesAddNatsDsnby@ekeewin#6874AddConfigDict.ser_json_inf_nanby@davidhewittin#8159Addtypes.OnErrorOmitby@adriangbin#8222SupportAliasGeneratorusage by@sydney-runklein#8282Add Pydantic People Page to docs by@sydney-runklein#8345Supportyyyy-MM-DDdatetime parsing by@sydney-runklein#8404Added bits conversions to theByteSizeclass#8415by@luca-mateiin#8507Enable json schema creation with typeByteSizeby@geospacklein#8537Addeval_type_backportto handle union operator and builtin generic subscripting in older Pythons by@alexmojakiin#8209Add support fordataclassfieldsinitby@dmontaguin#8552Implement pickling forValidationErrorby@davidhewittinpydantic/pydantic-core#1119Add unified tuple validator that can handle "variadic" tuples via PEP-646 by@dmontaguinpydantic/pydantic-core#865ChangesDrop Python3.7 support by@hramezaniin#7188Drop Python 3.7, and PyPy 3.7 and 3.8 by@davidhewittinpydantic/pydantic-core#1129Use positional-onlyselfinBaseModelconstructor, so no field name can ever conflict with it by@ariebovenbergin#8072Make@validate_callreturn a function instead of a custom descriptor - fixes binding issue with inheritance and addsself/clsargument to validation errors by@alexmojakiin#8268ExcludeBaseModeldocstring from JSON schema description by@sydney-runklein#8352Introducingclasspropertydecorator formodel_computed_fieldsby@Jocelyn-Gasin#8437Explicitly raise an error if field names clashes with types by@Viicosin#8243Use stricter serializer for unions of simple types by@alexdrydewpydantic/pydantic-core#1132PerformanceAdd Codspeed profiling Actions workflow  by@lambertsbennettin#8054Improveintextraction by@samuelcolvininpydantic/pydantic-core#1155Improve performance of recursion guard by@samuelcolvininpydantic/pydantic-core#1156dataclassserialization speedups by@samuelcolvininpydantic/pydantic-core#1162AvoidHashMapcreation when looking up small JSON objects inLazyIndexMapsby@samuelcolvininpydantic/jiter#55use hashbrown to speedup python string caching by@davidhewittinpydantic/jiter#51ReplacePeakwith more efficientPeekby@davidhewittinpydantic/jiter#48FixesMovegetattrwarning in deprecatedBaseConfigby@tlambert03in#7183Only hashmodel_fields, not whole__dict__by@alexmojakiin#7786Fix mishandling of unions while freezing types in themypyplugin by@dmontaguin#7411Fixmypyerror on untypedClassVarby@vincent-hachin-wmxin#8138Only compare pydantic fields inBaseModel.__eq__instead of whole__dict__by@QuentinSoubeyranAqemiain#7825Updatestrictdocstring inmodel_validatemethod. by@LukeToninin#8223Fix overload position ofcomputed_fieldby@Viicosin#8227Fix custom type type casting used in multiple attributes by@ianhfcin#8066Fix issue not allowingvalidate_calldecorator to be dynamically assigned to a class method by@jusextonin#8249Fix issueunittest.mockdeprecation warnings  by@ibleedicarein#8262Added tests for the caseJsonValuecontains subclassed primitive values by@jusextonin#8286Fixmypyerror on free before validator (classmethod) by@sydney-runklein#8285Fixto_snakeconversion by@jevins09in#8316Fix type annotation ofModelMetaclass.__prepare__by@slanzmichin#8305Disallowconfigspecification when initializing aTypeAdapterwhen the annotated type has config already by@sydney-runklein#8365Fix a naming issue with JSON schema for generics parametrized by recursive type aliases by@dmontaguin#8389Fix type annotation in pydantic people script by@shenxiangzhuangin#8402Add support for fieldaliasindataclasssignature by@NeevCohenin#8387Fix bug with schema generation withField(...)in a forward ref by@dmontaguin#8494Fix ordering of keys in__dict__withmodel_constructcall by@sydney-runklein#8500Fix modulepath_typecreation when globals does not contain__name__by@hramezaniin#8470Fix for namespace issue with dataclasses withfrom __future__ import annotationsby@sydney-runklein#8513Fix: make function validator types positional-only by@pmmmwhin#8479Fix usage of@deprecatedby@Viicosin#8294Add more support for private attributes inmodel_constructcall by@sydney-runklein#8525Use a stack for the types namespace by@dmontaguin#8378Fix schema-building bug withTypeAliasTypefor types with refs by@dmontaguin#8526Supportpydantic.Field(repr=False)in dataclasses by@tigeryy2in#8511Overridedataclass_transformbehavior forRootModelby@Viicosin#8163Refactor signature generation for simplicity by@sydney-runklein#8572Fix ordering bug of PlainValidator annotation by@Anvilin#8567Fixexclude_nonefor json serialization ofcomputed_fields by@sydney-runkleinpydantic/pydantic-core#1098Support yyyy-MM-DD string for datetimes by@sydney-runkleinpydantic/pydantic-core#1124Tweak ordering of definitions in generated schemas by@StrawHatDrag0nin#8583New Contributorspydantic@ekeewmade their first contribution in#6874@lambertsbennettmade their first contribution in#8054@vincent-hachin-wmxmade their first contribution in#8138@QuentinSoubeyranAqemiamade their first contribution in#7825@ariebovenbergmade their first contribution in#8072@LukeToninmade their first contribution in#8223@denisartmade their first contribution in#8231@ianhfcmade their first contribution in#8066@eonumade their first contribution in#8255@amandahlamade their first contribution in#8263@ibleedicaremade their first contribution in#8262@jevins09made their first contribution in#8316@cuu508made their first contribution in#8322@slanzmichmade their first contribution in#8305@jensenboxmade their first contribution in#8331@szepeviktormade their first contribution in#8356@Elkiwamade their first contribution in#8341@parhamfhmade their first contribution in#8395@shenxiangzhuangmade their first contribution in#8402@NeevCohenmade their first contribution in#8387@zbymade their first contribution in#8497@patelnetsmade their first contribution in#8491@edwardwlimade their first contribution in#8503@luca-mateimade their first contribution in#8507@Jocelyn-Gasmade their first contribution in#8437@bL34cHig0made their first contribution in#8501@tigeryy2made their first contribution in#8511@geospacklemade their first contribution in#8537@Anvilmade their first contribution in#8567@hungtsetsemade their first contribution in#8546@StrawHatDrag0nmade their first contribution in#8583pydantic-core@mariuswingermade their first contribution inpydantic/pydantic-core#1087@adamchainzmade their first contribution inpydantic/pydantic-core#1090@akxmade their first contribution inpydantic/pydantic-core#1123v2.6.0b1 (2024-01-19)Pre-release, seethe GitHub releasefor details.v2.5.3 (2023-12-22)GitHub releaseWhat's ChangedPackaginguprevpydantic-coreto 2.14.6FixesFix memory leak with recursive definitions creating reference cycles by@davidhewittinpydantic/pydantic-core#1125v2.5.2 (2023-11-22)GitHub releaseWhat's ChangedPackaginguprevpydantic-coreto 2.14.5New FeaturesAddConfigDict.ser_json_inf_nanby@davidhewittin#8159FixesFix validation ofLiteralfrom JSON keys when used asdictkey by@sydney-runkleinpydantic/pydantic-core#1075Fix bug recustom_initon members ofUnionby@sydney-runkleinpydantic/pydantic-core#1076FixJsonValueboolserialization by@sydney-runklein#8190Fix handling of unhashable inputs withLiteralinUnions by@sydney-runkleinpydantic/pydantic-core#1089v2.5.1 (2023-11-15)GitHub releaseWhat's ChangedPackaginguprev pydantic-core to 2.14.3 by@samuelcolvinin#8120FixesFix package description limit by@dmontaguin#8097FixValidateCallWrappererror when creating a model which has a@validate_callwrapped field annotation by@sydney-runklein#8110v2.5.0 (2023-11-13)GitHub releaseThe code released in v2.5.0 is functionally identical to that of v2.5.0b1.What's ChangedPackagingUpdate pydantic-core from 2.10.1 to 2.14.1, significant changes from these updates are described below, full changeloghereUpdate topyright==1.1.335by@Viicosin#8075New FeaturesAllow plugins to catch nonValidationErrorerrors by@adriangbin#7806Support__doc__argument increate_model()by@chris-spannin#7863Exposeregex_engineflag - meaning you can use with the Rust or Python regex libraries in constraints by@utkiniin#7768Save return type generated from type annotation inComputedFieldInfoby@alexmojakiin#7889Adoptingruffformatter by@Luca-Blightin#7930Addedvalidation_error_causeto config by@zakstuckein#7626Make path of the item to validate available in plugin by@hramezaniin#7861AddCallableDiscriminatorandTagby@dmontaguin#7983CallableDiscriminatorrenamed toDiscriminatorby@dmontaguin#8047Make union case tags affect union error messages by@dmontaguin#8001Addexamplesandjson_schema_extrato@computed_fieldby@alexmojakiin#8013AddJsonValuetype by@dmontaguin#7998Allowstras argument toDiscriminatorby@dmontaguin#8047AddSchemaSerializer.__reduce__method to enable pickle serialization by@edoakesinpydantic/pydantic-core#1006ChangesSignificant Change:replaceultra_strictwith 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@davidhewittinpydantic/pydantic-core#867Add support for instance method reassignment whenextra='allow'by@sydney-runklein#7683Support JSON schema generation forEnumtypes with no cases by@sydney-runklein#7927Warn if a class inherits fromGenericbeforeBaseModelby@alexmojakiin#7891PerformanceNew custom JSON parser,jiterby@samuelcolvininpydantic/pydantic-core#974PGO build for MacOS M1 by@samuelcolvininpydantic/pydantic-core#1063Use__getattr__for all package imports, improve import time by@samuelcolvinin#7947FixesFixmypyissue with subclasses ofRootModelby@sydney-runklein#7677Properly rebuild theFieldInfowhen a forward ref gets evaluated by@dmontaguin#7698Fix failure to loadSecretStrfrom JSON (regression in v2.4) by@sydney-runklein#7729Fixdefer_buildbehavior withTypeAdapterby@sydney-runklein#7736Improve compatibility with legacymypyversions by@dmontaguin#7742Fix: updateTypeVarhandling when default is not set by@pmmmwhin#7719Support specification ofstrictonEnumtype fields by@sydney-runklein#7761Wrapweakref.refinstead of subclassing to fixcloudpickleserialization by@edoakesin#7780Keep values of private attributes set withinmodel_post_initin subclasses by@alexmojakiin#7775Add more specific type for non-callablejson_schema_extraby@alexmojakiin#7803Raise an error when deleting frozen (model) fields by@alexmojakiin#7800Fix schema sorting bug with default values by@sydney-runklein#7817Use generated alias for aliases that are not specified otherwise by@alexmojakiin#7802Supportstrictspecification forUUIDtypes by@sydney-runklein#7865JSON schema: fix extra parameter handling by@me-andin#7810Fix: supportpydantic.Field(kw_only=True)with inherited dataclasses by@PrettyWoodin#7827Supportvalidate_calldecorator for methods in classes with__slots__by@sydney-runklein#7883Fix pydantic dataclass problem withdataclasses.fielddefault by@hramezaniin#7898Fix schema generation for generics with union type bounds by@sydney-runklein#7899Fix version forimportlib_metadataon python 3.7 by@sydney-runklein#7904Support|operator (Union) in PydanticRecursiveRef by@alexmojakiin#7892Fixdisplay_as_typeforTypeAliasTypein python 3.12 by@dmontaguin#7929Add support forNotRequiredgenerics inTypedDictby@sydney-runklein#7932Make genericTypeAliasTypespecifications produce different schema definitions by@alexdrydewin#7893Added fix for signature of inherited dataclass by@howsunjowin#7925Make the model name generation more robust in JSON schema by@joakimnordlingin#7881Fix plurals in validation error messages (in tests) by@Iipinin#7972PrivateAttris passed fromAnnotateddefault position by@tabasscoin#8004Don't decode bytes (which may not be UTF8) when displaying SecretBytes by@alexmojakiin#8012Useclassmethodinstead ofclassmethod[Any, Any, Any]by@Mr-Pepein#7979Clearer error on invalid Plugin by@samuelcolvinin#8023Correct pydantic dataclasses import by@samuelcolvinin#8027Fix misbehavior for models referencing redefined type aliases by@dmontaguin#8050FixOptionalfield withvalidate_defaultonly performing one field validation by@sydney-runkleinpydantic/pydantic-core#1002Fixdefinition-refbug withDictkeys by@sydney-runkleinpydantic/pydantic-core#1014Fix bug allowing validation ofbooltypes withcoerce_numbers_to_str=Trueby@sydney-runkleinpydantic/pydantic-core#1017Don't acceptNaNin float and decimal constraints by@davidhewittinpydantic/pydantic-core#1037Addlax_strandlax_intsupport for enum values not inherited from str/int by@michaelhlyinpydantic/pydantic-core#1015Support subclasses in lists inUnionofListtypes by@sydney-runkleinpydantic/pydantic-core#1039Allow validation againstmax_digitsanddecimalsto pass if normalized or non-normalized input is valid by@sydney-runkleinpydantic/pydantic-core#1049Fix: proper pluralization inValidationErrormessages by@Iipininpydantic/pydantic-core#1050Disallow the string'-'asdatetimeinput by@davidhewittinpydantic/speedate#52&pydantic/pydantic-core#1060Fix: NaN and Inf float serialization by@davidhewittinpydantic/pydantic-core#1062Restore manylinux-compatible PGO builds by@davidhewittinpydantic/pydantic-core#1068New Contributorspydantic@schneebuzzmade their first contribution in#7699@edoakesmade their first contribution in#7780@alexmojakimade their first contribution in#7775@NickG123made their first contribution in#7751@gowthamgtsmade their first contribution in#7830@jamesbrazamade their first contribution in#7848@laundmomade their first contribution in#7850@rahmatnazalimade their first contribution in#7870@waterfountain1996made their first contribution in#7878@chris-spannmade their first contribution in#7863@me-andmade their first contribution in#7810@utkinimade their first contribution in#7768@bn-lmade their first contribution in#7744@alexdrydewmade their first contribution in#7893@Luca-Blightmade their first contribution in#7930@howsunjowmade their first contribution in#7925@joakimnordlingmade their first contribution in#7881@icfly2made their first contribution in#7976@Yummy-Yumsmade their first contribution in#8003@Iipinmade their first contribution in#7972@tabasscomade their first contribution in#8004@Mr-Pepemade their first contribution in#7979@0x00clmade their first contribution in#8010@barrapontomade their first contribution in#8032pydantic-core@sispmade their first contribution inpydantic/pydantic-core#995@michaelhlymade their first contribution inpydantic/pydantic-core#1015v2.5.0b1 (2023-11-09)Pre-release, seethe GitHub releasefor details.v2.4.2 (2023-09-27)GitHub releaseWhat's ChangedFixesFix bug with JSON schema for sequence of discriminated union by@dmontaguin#7647Fix schema references in discriminated unions by@adriangbin#7646Fix json schema generation for recursive models by@adriangbin#7653Fixmodels_json_schemafor generic models by@adriangbin#7654Fix xfailed test for generic model signatures by@adriangbin#7658New Contributors@austinorrmade their first contribution in#7657@peterHoburgmade their first contribution in#7670v2.4.1 (2023-09-26)GitHub releaseWhat's ChangedPackagingUpdate pydantic-core to 2.10.1 by@davidhewittin#7633FixesSerialize unsubstituted type vars asAnyby@adriangbin#7606Remove schema building caches by@adriangbin#7624Fix an issue where JSON schema extras weren't JSON encoded by@dmontaguin#7625v2.4.0 (2023-09-22)GitHub releaseWhat's ChangedPackagingUpdate pydantic-core to 2.10.0 by@samuelcolvinin#7542New FeaturesAddBase64Urltypes by@dmontaguin#7286Implement optionalnumbertostrcoercion by@ligin#7508Allow access tofield_nameanddatain all validators if there is data and a field name by@samuelcolvinin#7542AddBaseModel.model_validate_stringsandTypeAdapter.validate_stringsby@hramezaniin#7552Add Pydanticpluginsexperimental implementation by@lig@samuelcolvinand@Kludexin#6820ChangesDo not overridemodel_post_initin subclass with private attrs by@Viicosin#7302Make fields with defaults not required in the serialization schema by default by@dmontaguin#7275MarkExtraas deprecated by@disruptedin#7299MakeEncodedStra dataclass by@Kludexin#7396Moveannotated_handlersto be public by@samuelcolvinin#7569PerformanceSimplify flattening and inlining ofCoreSchemaby@adriangbin#7523Remove unused copies inCoreSchemawalking by@adriangbin#7528Add caches for collecting definitions and invalid schemas from a CoreSchema by@adriangbin#7527Eagerly resolve discriminated unions and cache cases where we can't by@adriangbin#7529Replacedict.getanddict.setdefaultwith more verbose versions inCoreSchemabuilding hot paths by@adriangbin#7536Cache invalidCoreSchemadiscovery by@adriangbin#7535Allow disablingCoreSchemavalidation for faster startup times by@adriangbin#7565FixesFix config detection forTypedDictfrom grandparent classes by@dmontaguin#7272Fix hash function generation for frozen models with unusual MRO by@dmontaguin#7274Makestrictconfig overridable in field for Path by@hramezaniin#7281Useser_json_<timedelta|bytes>on default inGenerateJsonSchemaby@Kludexin#7269Adding a check that alias is validated as an identifier for Python by@andree0in#7319Raise an error when computed field overrides field by@sydney-runklein#7346Fix applyingSkipValidationto referenced schemas by@adriangbin#7381Enforce behavior of private attributes having double leading underscore by@ligin#7265Standardize__get_pydantic_core_schema__signature by@hramezaniin#7415Fix generic dataclass fields mutation bug (when usingTypeAdapter) by@sydney-runklein#7435FixTypeErroronmodel_validatorinwrapmode by@pmmmwhin#7496Improve enum error message by@hramezaniin#7506Makereprwork for instances that failed initialization when handlingValidationErrors by@dmontaguin#7439Fixed a regular expression denial of service issue by limiting whitespaces by@prodigysmlin#7360Fix handling ofUUIDvalues havingUUID.version=Noneby@ligin#7566Fix__iter__returning privatecached_propertyinfo by@sydney-runklein#7570Improvements to version info message by@samuelcolvinin#7594New Contributors@15498thmade their first contribution in#7238@GabrielCappellimade their first contribution in#7213@tobnimade their first contribution in#7184@redruin1made their first contribution in#7282@FacerAinmade their first contribution in#7288@acdhamade their first contribution in#7297@andree0made their first contribution in#7319@gordonhartmade their first contribution in#7375@pmmmwhmade their first contribution in#7496@disruptedmade their first contribution in#7299@prodigysmlmade their first contribution in#7360v2.3.0 (2023-08-23)GitHub release🔥 Remove orphaned changes file from repo by@ligin#7168Add copy button on documentation by@Kludexin#7190Fix docs on JSON type by@Kludexin#7189Update mypy 1.5.0 to 1.5.1 in CI by@hramezaniin#7191fix download links badge by@samuelcolvinin#7200add 2.2.1 to changelog by@samuelcolvinin#7212Make ModelWrapValidator protocols generic by@dmontaguin#7154CorrectField(..., exclude: bool)docs by@samuelcolvinin#7214Make shadowing attributes a warning instead of an error by@adriangbin#7193DocumentBase64StrandBase64Bytesby@Kludexin#7192Fixconfig.defer_buildfor serialization first cases by@samuelcolvinin#7024clean Model docstrings in JSON Schema by@samuelcolvinin#7210fix#7228(typo): docs invalidators.mdto correctvalidate_defaultkwarg by@lmmxin#7229✅ Implementtzinfo.fromutcmethod forTzInfoinpydantic-coreby@ligin#7019Support__get_validators__by@hramezaniin#7197v2.2.1 (2023-08-18)GitHub releaseMakexfailing test for root model extra stopxfailing by@dmontaguin#6937Optimize recursion detection by stopping on the second visit for the same object by@mciucuin#7160fix link in docs by@tlambert03in#7166Replace MiMalloc w/ default allocator by@adriangbinpydantic/pydantic-core#900Bump pydantic-core to 2.6.1 and prepare 2.2.1 release by@adriangbin#7176v2.2.0 (2023-08-17)GitHub releaseSplit "pipx install" setup command into two commands on the documentation site by@nomadmtbin#6869DeprecateField.includeby@hramezaniin#6852Fix typo in default factory error msg by@hramezaniin#6880Simplify handling of typing.Annotated in GenerateSchema by@dmontaguin#6887Re-enable fastapi tests in CI by@dmontaguin#6883Make it harder to hit collisions with json schema defrefs by@dmontaguin#6566Cleaner error for invalid input toPathfields by@samuelcolvinin#6903:memo: support Coordinate Type by@yezz123in#6906FixForwardRefwrapper for py 3.10.0 (shim until bpo-45166) by@randomirin#6919Fix misbehavior related to copying of RootModel by@dmontaguin#6918Fix issue with recursion error caused by ParamSpec by@dmontaguin#6923Add section about Constrained classes to the Migration Guide by@Kludexin#6924Usemainbranch for badge links by@Viicosin#6925Add test for v1/v2 Annotated discrepancy by@carlbordumin#6926Make the v1 mypy plugin work with both v1 and v2 by@dmontaguin#6921Fix issue where generic models couldn't be parametrized with BaseModel by@dmontaguin#6933Remove xfail for discriminated union with alias by@dmontaguin#6938add field_serializer to computed_field by@andreslisztin#6965Use union_schema with Type[Union[...]] by@JeanArhancetin#6952Fix inherited typeddict attributes / config by@adriangbin#6981fix dataclass annotated before validator called twice by@davidhewittin#6998Update test-fastapi deselected tests by@hramezaniin#7014Fix validator doc format by@hramezaniin#7015Fix typo in docstring of model_json_schema by@AdamVinch-Federatedin#7032remove unused "type ignores" with pyright by@samuelcolvinin#7026Add benchmark representing FastAPI startup time by@adriangbin#7030Fix json_encoders for Enum subclasses by@adriangbin#7029Update docstring ofser_json_bytesregarding base64 encoding by@Viicosin#7052Allow@validate_callto work on async methods by@adriangbin#7046Fix: mypy error withSettingsandSettingsConfigDictby@JeanArhancetin#7002Fix some typos (repeated words and it's/its) by@eumiroin#7063Fix the typo in docstring by@harunyasarin#7062Docs: Fix broken URL in the pydantic-settings package recommendation by@swetjenin#6995Handle constraints being applied to schemas that don't accept it by@adriangbin#6951Replace almost_equal_floats with math.isclose by@eumiroin#7082bump pydantic-core to 2.5.0 by@davidhewittin#7077Addshort_versionand use it in links by@hramezaniin#7115📝 Add usage link toRootModelby@Kludexin#7113Revert "Fix default port for mongosrv DSNs (#6827)" by@Kludexin#7116Clarify validate_default and _Unset handling in usage docs and migration guide by@benbenbangin#6950Tweak documentation ofField.excludeby@Viicosin#7086Do not requirevalidate_assignmentto useField.frozenby@Viicosin#7103tweaks to_core_utilsby@samuelcolvinin#7040Make DefaultDict working with set by@hramezaniin#7126Don't always require typing.Generic as a base for partially parametrized models by@dmontaguin#7119Fix issue with JSON schema incorrectly using parent class core schema by@dmontaguin#7020Fix xfailed test related to TypedDict and alias_generator by@dmontaguin#6940Improve error message for NameEmail by@dmontaguin#6939Fix generic computed fields by@dmontaguin#6988Reflect namedtuple default values during validation by@dmontaguin#7144Update dependencies, fix pydantic-core usage, fix CI issues by@dmontaguin#7150Add mypy 1.5.0 by@hramezaniin#7118Handle non-json native enum values by@adriangbin#7056documentround_tripin Json type documentation  by@jc-louisin#7137Relax signature checks to better support builtins and C extension functions as validators by@adriangbin#7101add union_mode='left_to_right' by@davidhewittin#7151Include an error message hint for inherited ordering by@yvalencia91in#7124Fix one docs link and resolve some warnings for two others by@dmontaguin#7153Include Field extra keys name in warning by@hramezaniin#7136v2.1.1 (2023-07-25)GitHub releaseSkip FieldInfo merging when unnecessary by@dmontaguin#6862v2.1.0 (2023-07-25)GitHub releaseAddStringConstraintsfor use as Annotated metadata by@adriangbin#6605Try to fix intermittently failing CI by@adriangbin#6683Remove redundant example of optional vs default. by@ehiggs-deliverectin#6676Docs update by@samuelcolvinin#6692Remove the Validate always section in validator docs by@adriangbin#6679Fix recursion error in json schema generation by@adriangbin#6720Fix incorrect subclass check for secretstr by@AlexVndnblckein#6730update pdm / pdm lockfile to 2.8.0 by@davidhewittin#6714unpin pdm on more CI jobs by@davidhewittin#6755improve source locations for auxiliary packages in docs by@davidhewittin#6749Assume builtins don't accept an info argument by@adriangbin#6754Fix bug where callinghelp(BaseModelSubclass)raises errors by@hramezaniin#6758Fix mypy plugin handling of@model_validator(mode="after")by@ljodalin#6753update pydantic-core to 2.3.1 by@davidhewittin#6756Mypy plugin for settings by@hramezaniin#6760UsecontentSchemakeyword for JSON schema by@dmontaguin#6715fast-path checking finite decimals by@davidhewittin#6769Docs update by@samuelcolvinin#6771Improve json schema doc by@hramezaniin#6772Update validator docs by@adriangbin#6695Fix typehint for wrap validator by@dmontaguin#6788🐛 Fix validation warning for unions of Literal and other type by@ligin#6628Update documentation for generics support in V2 by@tpdorseyin#6685add pydantic-core build info toversion_info()by@samuelcolvinin#6785Fix pydantic dataclasses that use slots with default values by@dmontaguin#6796Fix inheritance of hash function for frozen models by@dmontaguin#6789✨ AddSkipJsonSchemaannotation by@Kludexin#6653Error if an invalid field name is used with Field by@dmontaguin#6797AddGenericModeltoMOVED_IN_V2by@adriangbin#6776Remove unused code fromdocs/usage/types/custom.mdby@hramezaniin#6803Fixfloat->Decimalcoercion precision loss by@adriangbin#6810remove email validation from the north star benchmark by@davidhewittin#6816Fix link to mypy by@progsmilein#6824Improve initialization hooks example by@hramezaniin#6822Fix default port for mongosrv DSNs by@dmontaguin#6827Improve API documentation, in particular more links between usage and API docs by@samuelcolvinin#6780update pydantic-core to 2.4.0 by@davidhewittin#6831Fixannotated_types.MaxLenvalidator for custom sequence types by@ImogenBitsin#6809Update V1 by@hramezaniin#6833Make it so callable JSON schema extra works by@dmontaguin#6798Fix serialization issue withInstanceOfby@dmontaguin#6829Add back support forjson_encodersby@adriangbin#6811Update field annotations when building the schema by@dmontaguin#6838UseWeakValueDictionaryto fix generic memory leak by@dmontaguin#6681Addconfig.defer_buildto optionally make model building lazy by@samuelcolvinin#6823delegateUUIDserialization to pydantic-core by@davidhewittin#6850Updatejson_encodersdocs by@adriangbin#6848Fix error message forstaticmethod/classmethodorder with validate_call by@dmontaguin#6686Improve documentation forConfigby@samuelcolvinin#6847Update serialization doc to mentionField.excludetakes priority over call-timeinclude/excludeby@hramezaniin#6851Allow customizing core schema generation by makingGenerateSchemapublic by@adriangbin#6737v2.0.3 (2023-07-05)GitHub releaseMention PyObject (v1) moving to ImportString (v2) in migration doc by@slafsin#6456Fix release-tweet CI by@Kludexin#6461Revise the section on required / optional / nullable fields. by@ybresslerin#6468Warn if a type hint is not in fact a type by@adriangbin#6479Replace TransformSchema with GetPydanticSchema by@dmontaguin#6484Fix the un-hashability of various annotation types, for use in caching generic containers by@dmontaguin#6480PYD-164: Rework custom types docs by@adriangbin#6490Fix ci by@adriangbin#6507Fix forward ref in generic by@adriangbin#6511Fix generation of serialization JSON schemas for core_schema.ChainSchema by@dmontaguin#6515Document the change inField.aliasbehavior in Pydantic V2 by@hramezaniin#6508Give better error message attempting to compute the json schema of a model with undefined fields by@dmontaguin#6519Documentalias_priorityby@tpdorseyin#6520Add redirect for types documentation by@tpdorseyin#6513Allow updating docs without release by@samuelcolvinin#6551Ensure docs tests always run in the right folder by@dmontaguin#6487Defer evaluation of return type hints for serializer functions by@dmontaguin#6516Disable E501 from Ruff and rely on just Black by@adriangbin#6552Update JSON Schema documentation for V2 by@tpdorseyin#6492Add documentation of cyclic reference handling by@dmontaguin#6493Remove the need for change files by@samuelcolvinin#6556add "north star" benchmark by@davidhewittin#6547Update Dataclasses docs by@tpdorseyin#6470♻️ Use different error message on v1 redirects by@Kludexin#6595⬆ Upgradepydantic-coreto v2.2.0 by@ligin#6589Fix serialization for IPvAny by@dmontaguin#6572Improve CI by using PDM instead of pip to install typing-extensions by@adriangbin#6602Addenumerror type docs  by@ligin#6603🐛 Fixmax_lengthfor unicode strings by@ligin#6559Add documentation for accessing features viapydantic.v1by@tpdorseyin#6604Include extra when iterating over a model by@adriangbin#6562Fix typing of model_validator by@adriangbin#6514Touch up Decimal validator by@adriangbin#6327Fix various docstrings using fixed pytest-examples by@dmontaguin#6607Handle function validators in a discriminated union by@dmontaguin#6570Review json_schema.md by@tpdorseyin#6608Make validate_call work on basemodel methods by@dmontaguin#6569add test for big int json serde by@davidhewittin#6614Fix pydantic dataclass problem with dataclasses.field default_factory by@hramezaniin#6616Fixed mypy type inference for TypeAdapter by@zakstuckein#6617Make it work to use None as a generic parameter by@dmontaguin#6609Make it work to use$refas an alias by@dmontaguin#6568add note to migration guide about changes toAnyUrletc by@davidhewittin#6618🐛 Support definingjson_schema_extraonRootModelusingFieldby@ligin#6622Update pre-commit to prevent commits to main branch on accident by@dmontaguin#6636Fix PDM CI for python 3.7 on MacOS/windows by@dmontaguin#6627Produce more accurate signatures for pydantic dataclasses by@dmontaguin#6633Updates to Url types for Pydantic V2 by@tpdorseyin#6638Fix list markdown intransformdocstring by@StefanBRasin#6649simplify slots_dataclass construction to appease mypy by@davidhewittin#6639Update TypedDict schema generation docstring by@adriangbin#6651Detect and lint-error for prints by@dmontaguin#6655Add xfailing test for pydantic-core PR 766 by@dmontaguin#6641Ignore unrecognized fields from dataclasses metadata by@dmontaguin#6634Make non-existent class getattr a mypy error by@dmontaguin#6658Update pydantic-core to 2.3.0 by@hramezaniin#6648Use OrderedDict from typing_extensions by@dmontaguin#6664Fix typehint for JSON schema extra callable by@dmontaguin#6659v2.0.2 (2023-07-05)GitHub releaseFix bug where round-trip pickling/unpickling aRootModelwould change the value of__dict__,#6457by@dmontaguAllow single-item discriminated unions,#6405by@dmontaguFix issue with union parsing of enums,#6440by@dmontaguDocs: Fixedconstrdocumentation, renamed oldregexto newpattern,#6452by@miiliChangeGenerateJsonSchema.generate_definitionssignature,#6436by@dmontaguSee the full changelogherev2.0.1 (2023-07-04)GitHub releaseFirst patch release of Pydantic V2Extra fields added viasetattr(i.e.m.some_extra_field = 'extra_value')
are added to.model_extraifmodel_configextra='allowed'. Fixed#6333,#6365by@aaraneyAutomatically unpack JSON schema '$ref' for custom types,#6343by@adriangbFix tagged unions multiple processing in submodels,#6340by@suharnikovSee the full changelogherev2.0 (2023-06-30)GitHub releasePydantic V2 is here! :tada:Seethis postfor more details.v2.0b3 (2023-06-16)Third beta pre-release of Pydantic V2See the full changelogherev2.0b2 (2023-06-03)Addfrom_attributesruntime flag toTypeAdapter.validate_pythonandBaseModel.model_validate.See the full changelogherev2.0b1 (2023-06-01)First beta pre-release of Pydantic V2See the full changelogherev2.0a4 (2023-05-05)Fourth pre-release of Pydantic V2See the full changelogherev2.0a3 (2023-04-20)Third pre-release of Pydantic V2See the full changelogherev2.0a2 (2023-04-12)Second pre-release of Pydantic V2See the full changelogherev2.0a1 (2023-04-03)First pre-release of Pydantic V2!Seethis postfor more details.... seeherefor earlier changes.