Package: csvcubed-pydantic
pydanticData validation and settings management using Python type hinting.Fast and extensible,pydanticplays nicely with your linters/IDE/brain.
Define how data should be in pure, canonical Python 3.6+; validate it withpydantic.HelpSeedocumentationfor more details.InstallationInstall usingpip install -U pydanticorconda install pydantic -c conda-forge.
For more installation options to makepydanticeven faster,
see theInstallsection in the documentation.A Simple ExamplefromdatetimeimportdatetimefromtypingimportList,OptionalfrompydanticimportBaseModelclassUser(BaseModel):id:intname='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 topydantic, seeContributing to Pydantic.Reporting a Security VulnerabilitySee oursecurity policy.v1.9.0 (2021-12-31)Thank you to pydantic's sponsors:
@sthagen,@timdrijvers,@toinbis,@koxudaxi,@ginomempin,@primer-io,@and-semakin,@westonsteimel,@reillysiemens,
@es3n1n,@jokull,@JonasKs,@Rehket,@corleyma,@daddycocoaman,@hardbyte,@datarootsio,@jodal,@aminalaee,@rafsaf,
@jqueguiner,@chdsbd,@kevinalh,@Mazyod,@grillazz,@JonasKs,@simw,@leynier,@xfenixfor their kind support.Highlightsadd python 3.10 support,#2885by@PrettyWoodDiscriminated unions,#619by@PrettyWoodConfig.smart_unionfor better union logic,#2092by@PrettyWoodBinaries for Macos M1 CPUs,#3498by@samuelcolvinComplex types can be set vianested environment variables, e.g.foo___bar,#3159by@Air-Markadd a dark mode topydanticdocumentation,#2913by@gbdlinAdd support for autocomplete in VS Code via__dataclass_transform__,#2721by@tiangoloAdd "exclude" as a field parameter so that it can be configured using model config,#660by@daviskirkv1.9.0 (2021-12-31) ChangesApplyupdate_forward_refstoConfig.json_encodesprevent name clashes in types defined via strings,#3583by@samuelcolvinExtend pydantic's mypy plugin to support mypy versions0.910,0.920,0.921&0.930,#3573&#3594by@PrettyWood,@christianbundy,@samuelcolvinv1.9.0a2 (2021-12-24) Changessupport generic models with discriminated union,#3551by@PrettyWoodkeep old behaviour ofjson()by default,#3542by@PrettyWoodRemoved typing-only__root__attribute fromBaseModel,#3540by@laydayBuild Python 3.10 wheels,#3539by@mbachryFix display ofextrafields with model__repr__,#3234by@cocolmanmodels copied viaConfig.copy_on_model_validationalways have all fields,#3201by@PrettyWoodnested ORM from nested dictionaries,#3182by@PrettyWoodfix link to discriminated union section by@PrettyWoodv1.9.0a1 (2021-12-18) ChangesAdd support forDecimal-specific validation configurations inField(), additionally to usingcondecimal(),
to allow better support from editors and tooling,#3507by@tiangoloAddarm64binaries suitable for MacOS with an M1 CPU to PyPI,#3498by@samuelcolvinFix issue whereNonewas considered invalid when using aUniontype containingAnyorobject,#3444by@tharradineWhen generating field schema, pass optionalfieldargument (of typepydantic.fields.ModelField) to__modify_schema__()if present,#3434by@jasujmFix issue when pydantic fail to parsetyping.ClassVarstring type annotation,#3401by@uriyyoMention Python >= 3.9.2 as an alternative totyping_extensions.TypedDict,#3374by@BvB93Changed the validator method name in theCustom Errors exampleto more accurately describe what the validator is doing; changed fromname_must_contain_spacetovalue_must_equal_bar,#3327by@michaelrios28AddAmqpDsnclass,#3254by@kludexAlways useEnumvalue as default in generated JSON schema,#3190by@joaommartinsAdd support for Mypy 0.920,#3175by@christianbundyvalidate_argumentsnow supportsextracustomization (used to always beExtra.forbid),#3161by@PrettyWoodComplex types can be set by nested environment variables,#3159by@Air-MarkFix mypy plugin to collect fields based onpydantic.utils.is_valid_fieldso that it ignores untyped private variables,#3146by@hi-ogawafixvalidate_argumentsissue withConfig.validate_all,#3135by@PrettyWoodavoid dict coercion when using dict subclasses as field type,#3122by@PrettyWoodadd support forobjecttype,#3062by@PrettyWoodUpdates pydantic dataclasses to keep_specialproperties on parent classes,#3043by@zulrangAdd aTypedDictclass for error objects,#3038by@matthewhughes934Fix support for using a subclass of an annotation as a default,#3018by@JacobHayesmakecreate_model_from_typeddictmypy compliant,#3008by@PrettyWoodMake multiple inheritance work when usingPrivateAttr,#2989by@hmvpParse environment variables as JSON, if they have aUniontype with a complex subfield,#2936by@cbartzPreventStrictStrpermittingEnumvalues where the enum inherits fromstr,#2929by@samuelcolvinMakeSecretsSettingsSourceparse values being assigned to fields of complex types when sourced from a secrets file,
just as when sourced from environment variables,#2917by@davidmreedadd a dark mode topydanticdocumentation,#2913by@gbdlinMakepydantic-mypyplugin compatible withpyproject.tomlconfiguration, consistent withmypychanges.
See thedocfor more information,#2908by@jrwalkadd python 3.10 support,#2885by@PrettyWoodCorrectly parse generic models withJson[T],#2860by@geekingfrogUpdate contrib docs re: python version to use for building docs,#2856by@paxcodesClarify documentation aboutpydantic's support for custom validation and strict type checking,
despitepydanticbeing primarily a parsing library,#2855by@paxcodesFix schema generation forDequefields,#2810by@sergejkozinfix an edge case when mixing constraints andLiteral,#2794by@PrettyWoodFix postponed annotation resolution forNamedTupleandTypedDictwhen they're used directly as the type of fields
within Pydantic models,#2760by@jameysharpFix bug whenmypyplugin fails onconstructmethod call forBaseSettingsderived classes,#2753by@uriyyoAdd function overloading for apydantic.create_modelfunction,#2748by@uriyyoFix mypy plugin issue with self field declaration,#2743by@uriyyoThe colon at the end of the line "The fields which were supplied when user was initialised:" suggests that the code following it is related.
Changed it to a period,#2733by@krisaoeRenamed variableschematoschema_to avoid shadowing of global variable name,#2724by@shahriyarrAdd support for autocomplete in VS Code via__dataclass_transform__,#2721by@tiangoloadd missing type annotations inBaseConfigand handlemax_length = 0,#2719by@PrettyWoodChangeorm_modechecking to allow recursive ORM mode parsing with dicts,#2718by@nuno-andreAdd episode 313 of theTalk Python To Mepodcast, where Michael Kennedy and Samuel Colvin discusspydantic, to the docs,#2712by@RatulMaharajfix JSON schema generation when a field is of typeNamedTupleand has a default value,#2707by@PrettyWoodEnumfields now properly support extra kwargs in schema generation,#2697by@sammchardyMake serialization of referenced pydantic models possible,#2650by@PrettyWoodAdduniqueItemsoption toConstrainedList,#2618by@nuno-andreTry to evaluate forward refs automatically at model creation,#2588by@uriyyoSwitch docs preview and coverage display to usesmokeshow,#2580by@samuelcolvinAdd__version__attribute to pydantic module,#2572by@paxcodesAddpostgresql+asyncpg,postgresql+pg8000,postgresql+psycopg2,postgresql+psycopg2cffi,postgresql+py-postgresqlandpostgresql+pygresqlschemes forPostgresDsn,#2567by@postgres-asyncpgEnable the Hypothesis plugin to generate a constrained decimal when thedecimal_placesargument is specified,#2524by@cwe5590Allowcollections.abc.Callableto be used as type in python 3.9,#2519by@daviskirkDocumentation update how to custom compile pydantic when using pip install, small change insetup.pyto allow for custom CFLAGS when compiling,#2517by@peterroelantsremove side effect ofdefault_factoryto run it only once even ifConfig.validate_allis set,#2515by@PrettyWoodAdd lookahead to ip regexes forAnyUrlhosts. This allows urls with DNS labels
looking like IPs to validate as they are perfectly valid host names,#2512by@sbv-csisSetminItemsandmaxItemsin generated JSON schema for fixed-length tuples,#2497by@PrettyWoodAddstrictargument toconbytes,#2489by@koxudaxiSupport user defined generic field types in generic models,#2465by@daviskirkAdd an example and a short explanation of subclassingGetterDictto docs,#2463by@nuno-andreaddKafkaDsntype,HttpUrlnow has default port 80 for http and 443 for https,#2447by@MihanixAAddPastDateandFutureDatetypes,#2425by@KludexSupport generating schema forGenericfields with subtypes,#2375by@maximbergfix(encoder): serializeNameEmailto str,#2341by@alecgeronaaddConfig.smart_unionto prevent coercion inUnionif possible, seethe docfor more information,#2092by@PrettyWoodAdd ability to usetyping.Counteras a model field type,#2060by@uriyyoAdd parameterised subclasses to__bases__when constructing new parameterised classes, so thatA <: B => A[int] <: B[int],#2007by@diabolo-danCreateFileUrltype that allows URLs that conform toRFC 8089.
Addhost_requiredparameter, which isTrueby default (AnyUrland subclasses),FalseinRedisDsn,FileUrl,#1983by@vgerakaddconfrozenset(), analogous toconset()andconlist(),#1897by@PrettyWoodstop calling parent classroot_validatorif overridden,#1895by@PrettyWoodAddrepr(defaults toTrue) parameter toField, to hide it from the default representation of theBaseModel,#1831by@fnepAccept empty query/fragment URL parts,#1807by@xavierv1.8.2 (2021-05-11)!!! warning
A security vulnerability, level "moderate" is fixed in v1.8.2. Please upgradeASAP.
See security advisoryCVE-2021-29510Security fix:Fixdateanddatetimeparsing so passing either'infinity'orfloat('inf')(or their negative values) does not cause an infinite loop,
see security advisoryCVE-2021-29510fix schema generation with Enum by generating a valid name,#2575by@PrettyWoodfix JSON schema generation with aLiteralof an enum member,#2536by@PrettyWoodFix bug with configurations declarations that are passed as
keyword arguments during class creation,#2532by@uriyyoAllow passingjson_encodersin class kwargs,#2521by@laydaysupport arbitrary types with custom__eq__,#2483by@PrettyWoodsupportAnnotatedinvalidate_argumentsand in generic models with python 3.9,#2483by@PrettyWoodv1.8.1 (2021-03-03)Bug fixes for regressions and new features fromv1.8allow elements ofConfig.fieldto update elements of aField,#2461by@samuelcolvinfix validation with aBaseModelfield and a custom root type,#2449by@PrettyWoodexposePatternencoder tofastapi,#2444by@PrettyWoodenable the Hypothesis plugin to generate a constrained float when themultiple_ofargument is specified,#2442by@tobi-lipede-oodleAvoidRecursionErrorwhen using some types likeEnumorLiteralwith generic models,#2436by@PrettyWooddo not overwrite declared__hash__in subclasses of a model,#2422by@PrettyWoodfixmypycomplaints onPathandUUIDrelated custom types,#2418by@PrettyWoodSupport properly variable length tuples of compound types,#2416by@PrettyWoodv1.8 (2021-02-26)Thank you to pydantic's sponsors:
@jorgecarleitao,@BCarley,@chdsbd,@tiangolo,@matin,@linusg,@kevinalh,@koxudaxi,@timdrijvers,@mkeen,@meadsteve,
@ginomempin,@primer-io,@and-semakin,@tomthorogood,@AjitZK,@westonsteimel,@Mazyod,@christippett,@CarlosDomingues,
@Kludex,@r-m-nfor their kind support.HighlightsHypothesis pluginfor testing,#2097by@Zac-HDsupport forNamedTupleandTypedDict,#2216by@PrettyWoodSupportAnnotatedhints on model fields,#2147by@JacobHayesfrozenparameter onConfigto allow models to be hashed,#1880by@rhuilleChangesBreaking Change, remove old deprecation aliases from v1,#2415by@samuelcolvin:remove notes on migrating to v1 in docsremoveSchemawhich was replaced byFieldremoveConfig.case_insensitivewhich was replaced byConfig.case_sensitive(defaultFalse)removeConfig.allow_population_by_aliaswhich was replaced byConfig.allow_population_by_field_nameremovemodel.fieldswhich was replaced bymodel.__fields__removemodel.to_string()which was replaced bystr(model)removemodel.__values__which was replaced bymodel.__dict__Breaking Change:always validate only first sublevel items witheach_item.
There were indeed some edge cases with some compound types where the validated items were the last sublevel ones,#1933by@PrettyWoodUpdate docs extensions to fix local syntax highlighting,#2400by@daviskirkfix: allowutils.lenient_issubclassto handletyping.GenericAliasobjects likelist[str]in python >= 3.9,#2399by@daviskirkImprove field declaration forpydanticdataclassby allowing the usage ofpydanticFieldor'metadata'kwarg ofdataclasses.field,#2384by@PrettyWoodMakingtyping-extensionsa required dependency,#2368by@samuelcolvinMakeresolve_annotationsmore lenient, allowing for missing modules,#2363by@samuelcolvinAllow configuring models through class kwargs,#2356by@BobroniumPreventMappingsubclasses from always being coerced todict,#2325by@ofekfix: allowNonefor typeOptional[conset / conlist],#2320by@PrettyWoodSupport empty tuple type,#2318by@PrettyWoodfix:python_requiresmetadata to require >=3.6.1,#2306by@hukkinj1Properly encodeDecimalwith, or without any decimal places,#2293by@hultnerfix: update__fields_set__inBaseModel.copy(update=…),#2290by@PrettyWoodfix: keep order of fields withBaseModel.construct(),#2281by@PrettyWoodSupport generating schema for Generic fields,#2262by@maximbergFixvalidate_decoratorso**kwargsdoesn't exclude values when the keyword
has the same name as the*argsor**kwargsnames,#2251by@cybojenixPrevent overriding positional arguments with keyword arguments invalidate_arguments, as per behaviour with native functions,#2249by@cybojenixadd documentation forcon*type functions,#2242by@tayoogunbiyiSupport custom root type (aka__root__) when usingparse_obj()with nested models,#2238by@PrettyWoodSupport custom root type (aka__root__) withfrom_orm(),#2237by@PrettyWoodensure cythonized functions are left untouched when creating models, based on#1944by@kollmats,#2228by@samuelcolvinResolve forward refs for stdlib dataclasses converted intopydanticones,#2220by@PrettyWoodAdd support forNamedTupleandTypedDicttypes.
Those two types are now handled and validated when used insideBaseModelorpydanticdataclass.
Two utils are also addedcreate_model_from_namedtupleandcreate_model_from_typeddict,#2216by@PrettyWoodDo not ignore annotated fields when type isUnion[Type[...], ...],#2213by@PrettyWoodRaise a user-friendlyTypeErrorwhen aroot_validatordoes not return adict(e.g.None),#2209by@masalim2Add aFrozenSet[str]type annotation to theallowed_schemesargument on thestrict_urlfield type,#2198by@Midnighteraddallow_mutationconstraint toField,#2195by@sblack-usuAllowFieldwith adefault_factoryto be used as an argument to a function
decorated withvalidate_arguments,#2176by@thomascobbAllow non-existent secrets directory by only issuing a warning,#2175by@davidolrikfix URL regex to parse fragment without query string,#2168by@andrewmwhitefix: ensure to always return one of the values inLiteralfield type,#2166by@PrettyWoodSupporttyping.Annotatedhints on model fields. AFieldmay now be set in the type hint withAnnotated[..., Field(...); all other annotations are ignored but still visible withget_type_hints(..., include_extras=True),#2147by@JacobHayesAddedStrictBytestype as well asstrict=Falseoption toConstrainedBytes,#2136by@rlizzoaddedConfig.anystr_lowerandto_lowerkwarg toconstrandconbytes,#2134by@tayoogunbiyiSupport plaintyping.Tupletype,#2132by@PrettyWoodAdd a bound methodvalidateto functions decorated withvalidate_argumentsto validate parameters without actually calling the function,#2127by@PrettyWoodAdd the ability to customize settings sources (add / disable / change priority order),#2107by@kozlekFix mypy complaints about most custompydantictypes,#2098by@PrettyWoodAdd aHypothesisplugin for easierproperty-based testingwith Pydantic's custom types -usage details here,#2097by@Zac-HDadd validator forNone,NoneTypeorLiteral[None],#2095by@PrettyWoodHandle properly fields of typeCallablewith a default value,#2094by@PrettyWoodUpdatedcreate_modelreturn type annotation to return type which inherits from__base__argument,#2071by@uriyyoAdd mergedjson_encodersinheritance,#2064by@art049allow overwritingClassVars in sub-models without having to re-annotate them,#2061by@laydayadd default encoder forPatterntype,#2045by@PrettyWoodAddNonNegativeInt,NonPositiveInt,NonNegativeFloat,NonPositiveFloat,#1975by@mdavis-xyzUse % for percentage in string format of colors,#1960by@EdwardBettsFixed issue causingKeyErrorto be raised when building schema from multipleBaseModelwith the same names declared in separate classes,#1912by@JSextonnAddrediss(Redis over SSL) protocol toRedisDsnAllow URLs withoutuserpart (e.g.,rediss://:pass@localhost),#1911by@TrDexAdd a newfrozenboolean parameter toConfig(default:False).
Settingfrozen=Truedoes everything thatallow_mutation=Falsedoes, and also generates a__hash__()method for the model. This makes instances of the model potentially hashable if all the attributes are hashable,#1880by@rhuillefix schema generation with multiple Enums having the same name,#1857by@PrettyWoodAdded support for 13/19 digits VISA credit cards inPaymentCardNumbertype,#1416by@AlexanderSovfix: preventRecursionErrorwhile using recursiveGenericModels,#1370by@xpptuseenumfortyping.Literalin JSON schema,#1350by@PrettyWoodFix: some recursive models did not requireupdate_forward_refsand silently behaved incorrectly,#1201by@PrettyWoodFix bug where generic models with fields where the typevar is nested in another typea: List[T]are considered to be concrete. This allows these models to be subclassed and composed as expected,#947by@daviskirkAddConfig.copy_on_model_validationflag. When set toFalse,pydanticwill keep models used as fields
untouched on validation instead of reconstructing (copying) them,#265by@PrettyWoodv1.7.4 (2021-05-11)Security fix:Fixdateanddatetimeparsing so passing either'infinity'orfloat('inf')(or their negative values) does not cause an infinite loop,
See security advisoryCVE-2021-29510v1.7.3 (2020-11-30)Thank you to pydantic's sponsors:
@timdrijvers,@BCarley,@chdsbd,@tiangolo,@matin,@linusg,@kevinalh,@jorgecarleitao,@koxudaxi,@primer-api,
@mkeen,@meadstevefor their kind support.fix: set right default value for required (optional) fields,#2142by@PrettyWoodfix: supportunderscore_attrs_are_privatewith generic models,#2138by@PrettyWoodfix: update all modified field values inroot_validatorwhenvalidate_assignmentis on,#2116by@PrettyWoodAllow pickling ofpydantic.dataclasses.dataclassdynamically created from a built-indataclasses.dataclass,#2111by@aimestereoFix a regression where Enum fields would not propagate keyword arguments to the schema,#2109by@bm424Ignore__doc__as private attribute whenConfig.underscore_attrs_are_privateis set,#2090by@PrettyWoodv1.7.2 (2020-11-01)fix slowGenericModelconcrete model creation, allowGenericModelconcrete name reusing in module,#2078by@Bobroniumkeep the order of the fields whenvalidate_assignmentis set,#2073by@PrettyWoodforward all the params of the stdlibdataclasswhen converted intopydanticdataclass,#2065by@PrettyWoodv1.7.1 (2020-10-28)Thank you to pydantic's sponsors:
@timdrijvers,@BCarley,@chdsbd,@tiangolo,@matin,@linusg,@kevinalh,@jorgecarleitao,@koxudaxi,@primer-api,@mkeenfor their kind support.fix annotation ofvalidate_argumentswhen passing configuration as argument,#2055by@laydayFix mypy assignment error when usingPrivateAttr,#2048by@aphedgesfixunderscore_attrs_are_privatecausingTypeErrorwhen overriding__init__,#2047by@samuelcolvinFixed regression introduced in v1.7 involving exception handling in field validators whenvalidate_assignment=True,#2044by@johnsabathfix:pydanticdataclasscan inherit from stdlibdataclassandConfig.arbitrary_types_allowedis supported,#2042by@PrettyWoodv1.7 (2020-10-26)Thank you to pydantic's sponsors:
@timdrijvers,@BCarley,@chdsbd,@tiangolo,@matin,@linusg,@kevinalh,@jorgecarleitao,@koxudaxi,@primer-apifor their kind support.Highlightspython 3.9 support, thanks@PrettyWoodPrivate model attributes, thanks@Bobronium"secrets files" support inBaseSettings, thanks@mdgileneconvert stdlib dataclasses to pydantic dataclasses and use stdlib dataclasses in models, thanks@PrettyWoodChangesBreaking Change:remove__field_defaults__, adddefault_factorysupport withBaseModel.construct.
Use.get_default()method on fields in__fields__attribute instead,#1732by@PrettyWoodRearrange CI to run linting as a separate job, split install recipes for different tasks,#2020by@samuelcolvinAllows subclasses of generic models to make some, or all, of the superclass's type parameters concrete, while
also defining new type parameters in the subclass,#2005by@choogeboomCall validator with the correctvaluesparameter type inBaseModel.__setattr__,
whenvalidate_assignment = Truein model config,#1999by@me-ranshForcefields.Undefinedto be a singleton object, fixing inherited generic model schemas,#1981by@daviskirkInclude tests in source distributions,#1976by@sbrazAdd ability to usemin_length/max_lengthconstraints with secret types,#1974by@uriyyoAlso checkroot_validatorswhenvalidate_assignmentis on,#1971by@PrettyWoodFix const validators not running when custom validators are present,#1957by@hmvpadddequeto field types,#1935by@wozniaktyadd basic support for python 3.9,#1832by@PrettyWoodFix typo in the anchor of exporting_models.md#modelcopy and incorrect description,#1821by@KimMachineGunAdded ability forBaseSettingsto read "secret files",#1820by@mdgileneaddparse_raw_asutility function,#1812by@PrettyWoodSupport home directory relative paths fordotenvfiles (e.g.~/.env),#1803by@PrettyWoodClarify documentation forparse_fileto show that the argument
should be a filepathnot a file-like object,#1794by@mdavis-xyzFix false positive from mypy plugin when a class nested within aBaseModelis namedModel,#1770by@selimbadd basic support of Pattern type in schema generation,#1767by@PrettyWoodSupport custom title, description and default in schema of enums,#1748by@PrettyWoodProperly representLiteralEnums whenuse_enum_valuesis True,#1747by@noelevansAllows timezone information to be added to strings to be formatted as time objects. Permitted formats areZfor UTC
or an offset for absolute positive or negative time shifts. Or the timezone data can be omitted,#1744by@noelevansAdd stub__init__with python 3.6 signature forForwardRef,#1738by@sirtelemakFix behaviour with forward refs and optional fields in nested models,#1736by@PrettyWoodaddEnumandIntEnumas valid types for fields,#1735by@PrettyWoodChange default value of__module__argument ofcreate_modelfromNoneto'pydantic.main'.
Set reference of created concrete model to it's module to allow pickling (not applied to models created in
functions),#1686by@BobroniumAdd private attributes support,#1679by@Bobroniumaddconfigto@validate_arguments,#1663by@samuelcolvinAllow descendant Settings models to override env variable names for the fields defined in parent Settings models withenvin theirConfig. Previously onlyenv_prefixconfiguration option was applicable,#1561by@ojomioSupportref_templatewhen creating schema$refs,#1479by@kilo59Add a__call__stub toPyObjectso that mypy will know that it is callable,#1352by@brianmaissypydantic.dataclasses.dataclassdecorator now supports built-indataclasses.dataclass.
It is hence possible to convert an existingdataclasseasily to addpydanticvalidation.
Moreover nested dataclasses are also supported,#744by@PrettyWoodv1.6.2 (2021-05-11)Security fix:Fixdateanddatetimeparsing so passing either'infinity'orfloat('inf')(or their negative values) does not cause an infinite loop,
See security advisoryCVE-2021-29510v1.6.1 (2020-07-15)fix validation and parsing of nested models withdefault_factory,#1710by@PrettyWoodv1.6 (2020-07-11)Thank you to pydantic's sponsors:@matin,@tiangolo,@chdsbd,@jorgecarleitao, and 1 anonymous sponsor for their kind support.Modify validators forconlistandconsetto not havealways=True,#1682by@samuelcolvinadd port check toAnyUrl(can't exceed 65536) ports are 16 insigned bits:0 <= port <= 2**16-1src:rfc793 header format,#1654by@flapiliDocument defaultregexanchoring semantics,#1648by@yurikhanUsechain.from_iterablein class_validators.py. This is a faster and more idiomatic way of usingitertools.chain.
Instead of computing all the items in the iterable and storing them in memory, they are computed one-by-one and never
stored as a huge list. This can save on both runtime and memory space,#1642by@cool-RRAddconset(), analogous toconlist(),#1623by@patrickkwangmakepydanticerrors (un)pickable,#1616by@PrettyWoodAllow custom encoding fordotenvfiles,#1615by@PrettyWoodEnsureSchemaExtraCallableis always defined to get type hints on BaseConfig,#1614by@PrettyWoodUpdate datetime parser to support negative timestamps,#1600by@mlbicheUpdate mypy, removeAnyTypealias forType[Any],#1598by@samuelcolvinAdjust handling of root validators so that errors are aggregated fromallfailing root validators, instead of reporting on only the first root validator to fail,#1586by@beezeeMake__modify_schema__on Enums apply to the enum schema rather than fields that use the enum,#1581by@therefromhereFix behavior of__all__key when used in conjunction with index keys in advanced include/exclude of fields that are sequences,#1579by@xspirusSubclass validators do not run when referencing aListfield defined in a parent class wheneach_item=True. Added an example to the docs illustrating this,#1566by@samueldeklundchangeschema.field_class_to_schemato supportfrozensetin schema,#1557by@wangpeibaoCall__modify_schema__only for the field schema,#1552by@PrettyWoodMove the assignment offield.validate_alwaysinfields.pyso thealwaysparameter of validators work on inheritance,#1545by@dcHHHAdded support for UUID instantiation through 16 byte strings such asb'\x12\x34\x56\x78' * 4. This was done to supportBINARY(16)columns in sqlalchemy,#1541by@shawnwallAdd a test assertion thatdefault_factorycan return a singleton,#1523by@therefromhereAddNameEmail.__eq__so duplicateNameEmailinstances are evaluated as equal,#1514by@stephen-bunnAdd datamodel-code-generator link in pydantic document site,#1500by@koxudaxiAdded a "Discussion of Pydantic" section to the documentation, with a link to "Pydantic Introduction" video by Alexander Hultnér,#1499by@hultnerAvoid some side effects ofdefault_factoryby calling it only once
if possible and by not setting a default value in the schema,#1491by@PrettyWoodAdded docs about dumping dataclasses to JSON,#1487by@mikegrimaMakeBaseModel.__signature__class-only, so getting__signature__from model instance will raiseAttributeError,#1466by@Bobroniuminclude'format': 'password'in the schema for secret types,#1424by@atheuzModify schema constraints onConstrainedFloatso thatexclusiveMinimumand
minimum are not included in the schema if they are equal to-math.infandexclusiveMaximumandmaximumare not included if they are equal tomath.inf,#1417by@vdweesSquash internal__root__dicts in.dict()(and, by extension, in.json()),#1414by@patrickkwangMoveconstvalidator to post-validators so it validates the parsed value,#1410by@selimbFix model validation to handle nested literals, e.g.Literal['foo', Literal['bar']],#1364by@DBCerigoRemoveuser_required = TruefromRedisDsn, neither user nor password are required,#1275by@samuelcolvinRemove extraallOffrom schema for fields withUnionand customField,#1209by@mostaphaRoudsariUpdates OpenAPI schema generation to output all enums as separate models.
Instead of inlining the enum values in the model schema, models now use a$refproperty to point to the enum definition,#1173by@calvinwyoungv1.5.1 (2020-04-23)Signature generation withextra: allownever uses a field name,#1418by@prettywoodAvoid mutatingFielddefault value,#1412by@prettywoodv1.5 (2020-04-18)Make includes/excludes arguments for.dict(),._iter(), ..., immutable,#1404by@AlexECXAlways use a field's real name with includes/excludes inmodel._iter(), regardless ofby_alias,#1397by@AlexECXUpdate constr regex example to include start and end lines,#1396by@lmcnearneyConfirm that shallowmodel.copy()does make a shallow copy of attributes,#1383by@samuelcolvinRenamingmodel_nameargument ofmain.create_model()to__model_nameto allow usingmodel_nameas a field name,#1367by@kittipatvReplace raising of exception to silent passing  for non-Var attributes in mypy plugin,#1345by@b0g3rRemovetyping_extensionsdependency for python 3.8,#1342by@prettywoodMakeSecretStrandSecretBytesinitialization idempotent,#1330by@atheuzdocument making secret types dumpable using the json method,#1328by@atheuzMove all testing and build to github actions, add windows and macos binaries,
thank you@StephenBrown2for much help,#1326by@samuelcolvinfix card number length check inPaymentCardNumber,PaymentCardBrandnow inherits fromstr,#1317by@samuelcolvinHaveBaseModelinherit fromRepresentationto make mypy happy when overriding__str__,#1310by@FuegoFroAllowNoneas input to all optional list fields,#1307by@prettywoodAdddatetimefield todefault_factoryexample,#1301by@StephenBrown2Allow subclasses of known types to be encoded with superclass encoder,#1291by@StephenBrown2Exclude exported fields from all elements of a list/tuple of submodels/dicts with'__all__',#1286by@masalim2Add pydantic.color.Color objects as available input for Color fields,#1258by@leosussanIn examples, type nullable fields asOptional, so that these are valid mypy annotations,#1248by@kokesMakepattern_validator()accept pre-compiledPatternobjects. Fixstr_validator()return type tostr,#1237by@adamgregDocument how to manage Generics and inheritance,#1229by@esadruhnupdate_forward_refs()method of BaseModel now copies__dict__of class module instead of modyfying it,#1228by@paul-ilyinSupport instance methods and class methods with@validate_arguments,#1222by@samuelcolvinAdddefault_factoryargument toFieldto create a dynamic default value by passing a zero-argument callable,#1210by@prettywoodadd support forNewTypeofList,Optional, etc,#1207by@Kazyfix mypy signature forroot_validator,#1192by@samuelcolvinFixed parsing of nested 'custom root type' models,#1190by@ShadosAddvalidate_argumentsfunction decorator which checks the arguments to a function matches type annotations,#1179by@samuelcolvinAdd__signature__to models,#1034by@BobroniumRefactor._iter()method, 10x speed boost fordict(model),#1017by@Bobroniumv1.4 (2020-01-24)Breaking Change:alias precedence logic changed so aliases on a field always take priority over
an alias fromalias_generatorto avoid buggy/unexpected behaviour,
seeherefor details,#1178by@samuelcolvinAdd support for unicode and punycode in TLDs,#1182by@jamescurtinFixclsargument in validators during assignment,#1172by@samuelcolvincompleting Luhn algorithm forPaymentCardNumber,#1166by@cuencandresadd support for generics that implement__get_validators__like a custom data type,#1159by@tiangoloadd support for infinite generators withIterable,#1152by@tiangolofixurl_regexto accept schemas with+,-and.after the first character,#1142by@samuelcolvinmoveversion_info()toversion.py, suggest its use in issues,#1138by@samuelcolvinImprove pydantic import time by roughly 50% by deferring some module loading and regex compilation,#1127by@samuelcolvinFixEmailStrandNameEmailto accept instances of themselves in cython,#1126by@koxudaxiPass model class to theConfig.schema_extracallable,#1125by@therefromhereFix regex for username and password in URLs,#1115by@samuelcolvinAdd support for nested generic models,#1104by@dmontaguadd__all__to__init__.pyto prevent "implicit reexport" errors from mypy,#1072by@samuelcolvinAdd support for using "dotenv" files withBaseSettings,#1011by@acnebsv1.3 (2019-12-21)Changeschemaandschema_modelto handle dataclasses by using their__pydantic_model__feature,#792by@aviramhaAdded option forroot_validatorto be skipped if values validation fails using keywordskip_on_failure=True,#1049by@aviramhaAllowConfig.schema_extrato be a callable so that the generated schema can be post-processed,#1054by@selimbUpdate mypy to version 0.750,#1057by@dmontaguTrick Cython into allowing str subclassing,#1061by@skewtyPrevent type attributes being added to schema unless the attribute__schema_attributes__isTrue,#1064by@samuelcolvinChangeBaseModel.parse_fileto useConfig.json_loads,#1067by@kierandarcyFix for optionalJsonfields,#1073by@volker48Change the default number of threads used when compiling with cython to one,
allow override via theCYTHON_NTHREADSenvironment variable,#1074by@samuelcolvinRun FastAPI tests during Pydantic's CI tests,#1075by@tiangoloMy mypy strictness constraints, and associated tweaks to type annotations,#1077by@samuelcolvinAdd__eq__to SecretStr and SecretBytes to allow "value equals",#1079by@sbv-trueenergyFix schema generation for nested None case,#1088by@lutostagConsistent checks for sequence like objects,#1090by@samuelcolvinFixConfiginheritance onBaseSettingswhen used withenv_prefix,#1091by@samuelcolvinFix for__modify_schema__when it conflicted withfield_class_to_schema*,#1102by@samuelcolvindocs: Fix explanation of case sensitive environment variable names when populatingBaseSettingssubclass attributes,#1105by@tribalsRename django-rest-framework benchmark in documentation,#1119by@frankie567v1.2 (2019-11-28)Possible Breaking Change:Add support for requiredOptionalwithname: Optional[AnyType] = Field(...)and refactorModelFieldcreation to preserverequiredparameter value,#1031by@tiangolo;
seeherefor detailsAdd benchmarks forcattrs,#513by@sebastianmikaAddexclude_noneoption todict()and friends,#587by@niknetnikoAdd benchmarks forvalideer,#670by@gsakkisAddparse_obj_asandparse_file_asfunctions for ad-hoc parsing of data into arbitrary pydantic-compatible types,#934by@dmontaguAddallow_reuseargument to validators, thus allowing validator reuse,#940by@dmontaguAdd support for mapping types for custom root models,#958by@dmontaguMypy plugin support for dataclasses,#966by@koxudaxiAdd support for dataclasses default factory,#968by@ahirnerAdd aByteSizetype for converting byte string (1GB) to plain bytes,#977by@dgasmithFix mypy complaint about@root_validator(pre=True),#984by@samuelcolvinAdd manylinux binaries for python 3.8 to pypi, also support manylinux2010,#994by@samuelcolvinAdds ByteSize conversion to another unit,#995by@dgasmithFix__str__and__repr__inheritance for models,#1022by@samuelcolvinadd testimonials section to docs,#1025by@sullivancolinAdd support fortyping.Literalfor Python 3.8,#1026by@dmontaguv1.1.1 (2019-11-20)Fix bug where use of complex fields on sub-models could cause fields to be incorrectly configured,#1015by@samuelcolvinv1.1 (2019-11-07)Add a mypy plugin for type checkingBaseModel.__init__and more,#722by@dmontaguChange return type typehint forGenericModel.__class_getitem__to prevent PyCharm warnings,#936by@dmontaguFix usage ofAnyto allowNone, also supportTypeVarthus allowing use of un-parameterised collection types
e.g.DictandList,#962by@samuelcolvinSetFieldInfoon subfields to fix schema generation for complex nested types,#965by@samuelcolvinv1.0 (2019-10-23)Breaking Change:deprecate theModel.fieldsproperty, useModel.__fields__instead,#883by@samuelcolvinBreaking Change:Change the precedence of aliases so child model aliases override parent aliases,
including usingalias_generator,#904by@samuelcolvinBreaking change:Renameskip_defaultstoexclude_unset, and add ability to exclude actual defaults,#915by@dmontaguAdd**kwargstopydantic.main.ModelMetaclass.__new__so__init_subclass__can take custom parameters on extendedBaseModelclasses,#867by@retniktFix field of a type that has a default value,#880by@koxudaxiUseFutureWarninginstead ofDeprecationWarningwhenaliasinstead ofenvis used for settings models,#881by@samuelcolvinFix issue withBaseSettingsinheritance andaliasgetting set toNone,#882by@samuelcolvinModify__repr__and__str__methods to be consistent across all public classes, add__pretty__to support
python-devtools,#884by@samuelcolvindeprecation warning forcase_insensitiveonBaseSettingsconfig,#885by@samuelcolvinForBaseSettingsmerge environment variables and in-code values recursively, as long as they create a valid object
when merged together, to allow splitting init arguments,#888by@idmitrievskychange secret types example,#890by@ashearsChange the signature ofModel.construct()to be more user-friendly, documentconstruct()usage,#898by@samuelcolvinAdd example for theconstruct()method,#907by@ashearsImprove use ofFieldconstraints on complex types, raise an error if constraints are not enforceable,
also support tuples with an ellipsisTuple[X, ...],SequenceandFrozenSetin schema,#909by@samuelcolvinupdate docs for bool missing valid value,#911by@trim21Betterstr/reprlogic forModelField,#912by@samuelcolvinFixConstrainedList, update schema generation to reflectmin_itemsandmax_itemsField()arguments,#917by@samuelcolvinAllow abstracts sets (eg. dict keys) in theincludeandexcludearguments ofdict(),#921by@samuelcolvinFix JSON serialization errors onValidationError.json()by usingpydantic_encoder,#922by@samuelcolvinClarify usage ofremove_untouched, improve error message for types with no validators,#926by@retniktv1.0b2 (2019-10-07)MarkStrictBooltypecheck asboolto allow for default values without mypy errors,#690by@dmontaguTransfer the documentation build from sphinx to mkdocs, re-write much of the documentation,#856by@samuelcolvinAdd support for custom naming schemes forGenericModelsubclasses,#859by@dmontaguAddif TYPE_CHECKING:to the excluded lines for test coverage,#874by@dmontaguRenameallow_population_by_aliastoallow_population_by_field_name, remove unnecessary warning about it,#875by@samuelcolvinv1.0b1 (2019-10-01)Breaking Change:renameSchematoField, make it a function to placate mypy,#577by@samuelcolvinBreaking Change:modify parsing behavior forbool,#617by@dmontaguBreaking Change:get_validatorsis no longer recognised, use__get_validators__.Config.ignore_extraandConfig.allow_extraare no longer recognised, useConfig.extra,#720by@samuelcolvinBreaking Change:modify default config settings forBaseSettings;case_insensitiverenamed tocase_sensitive,
default changed tocase_sensitive = False,env_prefixdefault changed to''- e.g. no prefix,#721by@dmontaguBreaking change:Implementroot_validatorand rename root errors from__obj__to__root__,#729by@samuelcolvinBreaking Change:alter the behaviour ofdict(model)so that sub-models are nolonger
converted to dictionaries,#733by@samuelcolvinBreaking change:Addedinitvarssupport topost_init_post_parse,#748by@Raphael-C-AlmeidaBreaking Change:MakeBaseModel.json()only serialize the__root__key for models with custom root,#752by@dmontaguBreaking Change:complete rewrite ofURLparsing logic,#755by@samuelcolvinBreaking Change:preserve superclass annotations for field-determination when not provided in subclass,#757by@dmontaguBreaking Change:BaseSettingsnow uses the specialenvsettings to define which environment variables to
read, not aliases,#847by@samuelcolvinadd support forassertstatements inside validators,#653by@abduscoUpdate documentation to specify the use ofpydantic.dataclasses.dataclassand subclassingpydantic.BaseModel,#710by@maddosaurusAllow custom JSON decoding and encoding viajson_loadsandjson_dumpsConfigproperties,#714by@samuelcolvinmake all annotated fields occur in the order declared,#715by@dmontaguuse pytest to testmypyintegration,#735by@dmontaguadd__repr__method toErrorWrapper,#738by@samuelcolvinAdded support forFrozenSetmembers in dataclasses, and a better error when attempting to use types from thetypingmodule that are not supported by Pydantic,#745by@djpettiadd documentation for Pycharm Plugin,#750by@koxudaxifix broken examples in the docs,#753by@dmontagumoving typing related objects intopydantic.typing,#761by@samuelcolvinMinor performance improvements toErrorWrapper,ValidationErrorand datetime parsing,#763by@samuelcolvinImprovements todatetime/date/time/timedeltatypes: more descriptive errors,
change errors tovalue_errornottype_error, support bytes,#766by@samuelcolvinfix error messages forLiteraltypes with multiple allowed values,#770by@dmontaguImproved auto-generatedtitlefield in JSON schema by converting underscore to space,#772by@skewtysupportmypy --no-implicit-reexportfor dataclasses, also respect--no-implicit-reexportin pydantic itself,#783by@samuelcolvinadd thePaymentCardNumbertype,#790by@matinFix const validations for lists,#794by@hmvpSetadditionalPropertiesto false in schema for models with extra fields disallowed,#796by@Code0x58EmailStrvalidation method now returns local part case-sensitive per RFC 5321,#798by@henriklindgrenAdded ability to validate strictness toConstrainedFloat,ConstrainedIntandConstrainedStrand addedStrictFloatandStrictIntclasses,#799by@DerRiddaImprove handling ofNoneandOptional, replacewholewitheach_item(inverse meaning, defaultFalse)
on validators,#803by@samuelcolvinadd support forType[T]type hints,#807by@timonbimonPerformance improvements from removingchange_exceptions, change how pydantic error are constructed,#819by@samuelcolvinFix the error message arising when aBaseModel-type model field causes aValidationErrorduring parsing,#820by@dmontaguallowgetter_dictonConfig, modifyGetterDictto be more like aMappingobject and thus easier to work with,#821by@samuelcolvinOnly checkTypeVarparam on baseGenericModelclass,#842by@zpencerqrenameModel._schema_cache->Model.__schema_cache__,Model._json_encoder->Model.__json_encoder__,Model._custom_root_type->Model.__custom_root_type__,#851by@samuelcolvinv0.32.2 (2019-08-17)(Docs are availablehere)fix__post_init__usage with dataclass inheritance, fix#739by@samuelcolvinfix required fields validation on GenericModels classes,#742by@amitblfix defining customSchemaonGenericModelfields,#754by@amitblv0.32.1 (2019-08-08)do not validate extra fields whenvalidate_assignmentis on,#724by@YaraslauZhylkov0.32 (2019-08-06)add model name toValidationErrorerror message,#676by@dmontagubreaking change: remove__getattr__and rename__values__to__dict__onBaseModel,
deprecation warning on use__values__attr, attributes access speed increased up to 14 times,#712by@BobroniumsupportForwardRef(without self-referencing annotations) in Python 3.6,#706by@koxudaxiimplementschema_extrainConfigsub-class,#663by@tiangolov0.31.1 (2019-07-31)fix json generation forEnumError,#697by@dmontaguupdate numerous dependenciesv0.31 (2019-07-24)better support for floating pointmultiple_ofvalues,#652by@justindujardinfix schema generation forNewTypeandLiteral,#649by@dmontagufixalias_generatorand field config conflict,#645by@gmetzkerand#658by@Bobroniummore detailed message forEnumError,#673by@dmontaguadd advanced exclude support fordict,jsonandcopy,#648by@Bobroniumfix bug inGenericModelfor models with concrete parameterized fields,#672by@dmontaguadd documentation forLiteraltype,#651by@dmontaguaddConfig.keep_untouchedfor custom descriptors support,#679by@Bobroniumuseinspect.cleandocinternally to get model description,#657by@tiangoloaddColorto schema generation, by@euri10add documentation for Literal type,#651by@dmontaguv0.30.1 (2019-07-15)fix so nested classes which inherit and change__init__are correctly processed while still allowingselfas a
parameter,#644by@lnadenand@dgasmithv0.30 (2019-07-07)enforce single quotes in code,#612by@samuelcolvinfix infinite recursion with dataclass inheritance and__post_init__,#606by@Hanaasagifix default values forGenericModel,#610by@dmontaguclarify that self-referencing models require python 3.7+,#616by@vlcinskyfix truncate for types,#611by@dmontaguaddalias_generatorsupport,#622by@Bobroniumfix unparameterized generic type schema generation,#625by@dmontagufix schema generation with multiple/circular references to the same model,#621by@tiangoloand@wongpatsupport custom root types,#628by@koxudaxisupportselfas a field name inparse_obj,#632by@samuelcolvinv0.29 (2019-06-19)support dataclasses.InitVar,#592by@pfrederiksUpdated documentation to elucidate the usage ofUnionwhen defining multiple types under an attribute's
annotation and showcase how the type-order can affect marshalling of provided values,#594by@somada141addconlisttype,#583by@hmvpadd support for generics,#595by@dmontaguv0.28 (2019-06-06)fix support for JSON Schema generation when using models with circular references in Python 3.7,#572by@tiangolosupport__post_init_post_parse__on dataclasses,#567by@sevahoallow dumping dataclasses to JSON,#575by@samuelcolvinand@DanielObergORM mode,#562by@samuelcolvinfixpydantic.compiledon ipython,#573by@dmontaguand@samuelcolvinaddStrictBooltype,#579by@cazgpv0.27 (2019-05-30)breaking change_pydantic_post_initto execute dataclass' original__post_init__before
validation,#560by@HeavenVolkofffix handling of generic types without specified parameters,#550by@dmontagubreaking change(maybe): this is the first release compiled withcython, see the docs and please
submit an issue if you run into problemsv0.27.0a1 (2019-05-26)fix JSON Schema forlist,tuple, andset,#540by@tiangolocompiling with cython,manylinuxbinaries, some other performance improvements,#548by@samuelcolvinv0.26 (2019-05-22)fix to schema generation forIPvAnyAddress,IPvAnyInterface,IPvAnyNetwork#498by@pilosusfix variable length tuples support,#495by@pilosusfix return type hint forcreate_model,#526by@dmontaguBreaking Change:fix.dict(skip_keys=True)skipping values set via alias (this involves changingvalidate_model()to always returnsTuple[Dict[str, Any], Set[str], Optional[ValidationError]]),#517by@sommdfix to schema generation forIPv4Address,IPv6Address,IPv4Interface,IPv6Interface,IPv4Network,IPv6Network#532by@euri10addColortype,#504by@pilosusand@samuelcolvinv0.25 (2019-05-05)Improve documentation on self-referencing models and annotations,#487by@theenglishwayfix.dict()with extra keys,#490by@JaewonKimsupportconstkeyword inSchema,#434by@Sean1708v0.24 (2019-04-23)fix handlingForwardRefin sub-types, likeUnion,#464by@tiangolofix secret serialization,#465by@atheuzSupport custom validators for dataclasses,#454by@primal100fixparse_objto cope with dict-like objects,#472by@samuelcolvinfix to schema generation in nested dataclass-based models,#474by@NoAnyLovefixjsonforPath,FilePath, andDirectoryPathobjects,#473by@mikegoodspeedv0.23 (2019-04-04)improve documentation for contributing section,#441by@pilosusimprove README.rst to include essential information about the package,#446by@pilosusIntEnumsupport,#444by@potykionfix PyObject callable value,#409by@pilosusfixblackdeprecation warnings after update,#451by@pilosusfixForwardRefcollection bug,#450by@tigerwingsSupport specializedClassVars,#455by@tyrylufix JSON serialization foripaddresstypes,#333by@pilosusaddSecretStrandSecretBytestypes,#452by@atheuzv0.22 (2019-03-29)addIPv{4,6,Any}NetworkandIPv{4,6,Any}Interfacetypes fromipaddressstdlib,#333by@pilosusadd docs fordatetimetypes,#386by@pilosusfix to schema generation in dataclass-based models,#408by@pilosusfix path in nested models,#437by@kataevaddSequencesupport,#304by@pilosusv0.21.0 (2019-03-15)fix typo inNoneIsNotAllowedErrormessage,#414by@YaraslauZhylkoaddIPvAnyAddress,IPv4AddressandIPv6Addresstypes,#333by@pilosusv0.20.1 (2019-02-26)fix type hints ofparse_objand similar methods,#405by@erosenninfix submodel validation,#403by@samuelcolvincorrect type hints forValidationError.json,#406by@laydayv0.20.0 (2019-02-18)fix tests for python 3.8,#396by@samuelcolvinAdds fields to thedirmethod for autocompletion in interactive sessions,#398by@dgasmithsupportForwardRef(and thereforefrom __future__ import annotations) with dataclasses,#397by@samuelcolvinv0.20.0a1 (2019-02-13)breaking change(maybe): more sophisticated argument parsing for validators, any subset ofvalues,configandfieldis now permitted, eg.(cls, value, field),
however the variadic key word argument ("**kwargs")mustbe calledkwargs,#388by@samuelcolvinbreaking change: Addsskip_defaultsargument toBaseModel.dict()to allow skipping of fields that
were not explicitly set, signature ofModel.construct()changed,#389by@dgasmithaddpy.typedmarker file for PEP-561 support,#391by@je-lFixextrabehaviour for multiple inheritance/mix-ins,#394by@YaraslauZhylkov0.19.0 (2019-02-04)SupportCallabletype hint, fix#279by@proofit404Fix schema for fields withvalidatordecorator, fix#375by@tiangoloAddmultiple_ofconstraint toConstrainedDecimal,ConstrainedFloat,ConstrainedIntand their related typescondecimal,confloat, andconint#371, thanks@StephenBrown2Deprecatedignore_extraandallow_extraConfig fields in favor ofextra,#352by@liiightAdd type annotations to all functions, test fully with mypy,#373by@samuelcolvinfix for 'missing' error withvalidate_allorvalidate_always,#381by@samuelcolvinChange the second/millisecond watershed for date/datetime parsing to2e10,#385by@samuelcolvinv0.18.2 (2019-01-22)Fix to schema generation withOptionalfields, fix#361by@samuelcolvinv0.18.1 (2019-01-17)addConstrainedBytesandconbytestypes,#315@Gr1NaddingMANIFEST.into include license in package.tar.gz,#358by@samuelcolvinv0.18.0 (2019-01-13)breaking change: don't call validators on keys of dictionaries,#254by@samuelcolvinFix validators withalways=Truewhen the default isNoneor the type is optional, also preventwholevalidators being called for sub-fields, fix#132by@samuelcolvinimprove documentation for settings priority and allow it to be easily changed,#343by@samuelcolvinfixignore_extra=Falseandallow_population_by_alias=True, fix#257by@samuelcolvinbreaking change: SetBaseConfigattributesmin_anystr_lengthandmax_anystr_lengthtoNoneby default, fix#349in#350by@tiangoloadd support for postponed annotations,#348by@samuelcolvinv0.17.0 (2018-12-27)fix schema fortimedeltaas number,#325by@tiangoloprevent validators being called repeatedly after inheritance,#327by@samuelcolvinprevent duplicate validator check in ipython, fix#312by@samuelcolvinadd "Using Pydantic" section to docs,#323by@tiangolo&#326by@samuelcolvinfix schema generation for fields annotated as: dict,: list,: tupleand: set,#330&#335by@nkoninadd support for constrained strings as dict keys in schema,#332by@tiangolosupport for passing Config class in dataclasses decorator,#276by@jarekkar(breaking change: this supersedes thevalidate_assignmentargument withconfig)support for nested dataclasses,#334by@samuelcolvinbetter errors when getting anImportErrorwithPyObject,#309by@samuelcolvinrenameget_validatorsto__get_validators__, deprecation warning on use of old name,#338by@samuelcolvinsupportClassVarby excluding such attributes from fields,#184by@samuelcolvinv0.16.1 (2018-12-10)fixcreate_modelto correctly use the passed__config__,#320by@hugoduncanv0.16.0 (2018-12-03)breaking change: refactor schema generation to be compatible with JSON Schema and OpenAPI specs,#308by@tiangoloaddschematoschemamodule to generate top-level schemas from base models,#308by@tiangoloadd additional fields toSchemaclass to declare validation forstrand numeric values,#311by@tiangolorename_schematoschemaon fields,#318by@samuelcolvinaddcase_insensitiveoption toBaseSettingsConfig,#277by@jasonkuhrtv0.15.0 (2018-11-18)move codebase to use black,#287by@samuelcolvinfix alias use in settings,#286by@jasonkuhrtand@samuelcolvinfix datetime parsing inparse_date,#298by@samuelcolvinallow dataclass inheritance, fix#293by@samuelcolvinfixPyObject = None, fix#305by@samuelcolvinallowPatterntype, fix#303by@samuelcolvinv0.14.0 (2018-10-02)dataclasses decorator,#269by@Gauntand@samuelcolvinv0.13.1 (2018-09-21)fix issue where int_validator doesn't cast aboolto anint#264by@nphyattadd deep copy support forBaseModel.copy()#249,@gangeforsv0.13.0 (2018-08-25)raise an exception if a field's name shadows an existingBaseModelattribute#242addUrlStrandurlstrtypes#236timedelta json encoding ISO8601 and total seconds, custom json encoders#247, by@cfkanesanand@samuelcolvinallowtimedeltaobjects as values for properties of typetimedelta(matchesdatetimeetc. behavior)#247v0.12.1 (2018-07-31)fix schema generation for fields defined usingtyping.Any#237v0.12.0 (2018-07-31)addby_aliasargument in.dict()and.json()model methods#205add Json type support#214support tuples#227major improvements and changes to schema#213v0.11.2 (2018-07-05)addNewTypesupport#115fixlist,set&tuplevalidation#225separate outvalidate_modelmethod, allow errors to be returned along with valid values#221v0.11.1 (2018-07-02)support Python 3.7#216, thanks@laydayAllow arbitrary types in model#209, thanks@oldPadavanv0.11.0 (2018-06-28)makelist,tupleandsettypes stricter#86breaking change: remove msgpack parsing#201addFilePathandDirectoryPathtypes#10model schema generation#190JSON serialisation of models and schemas#133v0.10.0 (2018-06-11)addConfig.allow_population_by_alias#160, thanks@bendemareebreaking change: new errors format#179, thanks@Gr1Nbreaking change: removedConfig.min_number_sizeandConfig.max_number_size#183, thanks@Gr1Nbreaking change: correct behaviour ofltandgtarguments toconintetc.#188for the old behaviour useleandge#194, thanks@jahebaadded error context and ability to redefine error message templates usingConfig.error_msg_templates#183,
thanks@Gr1Nfix typo in validator exception#150copy defaults to model values, so different models don't share objects#154v0.9.1 (2018-05-10)allow customget_field_configon config classes#159addUUID1,UUID3,UUID4andUUID5types#167, thanks@Gr1Nmodify some inconsistent docstrings and annotations#173, thanks@YannLuofix type annotations for exotic types#171, thanks@Gr1Nre-use type validators in exotic types#171scheduled monthly requirements updates#168addDecimal,ConstrainedDecimalandcondecimaltypes#170, thanks@Gr1Nv0.9.0 (2018-04-28)tweak email-validator import error message#145fix parse error ofparse_date()andparse_datetime()when input is 0#144, thanks@YannLuoaddConfig.anystr_strip_whitespaceandstrip_whitespacekwarg toconstr,
by default values isFalse#163, thanks@Gr1NaddConstrainedFloat,confloat,PositiveFloatandNegativeFloattypes#166, thanks@Gr1Nv0.8.0 (2018-03-25)fix type annotation forinherit_config#139breaking change: check for invalid field names in validators#140validate attributes of parent models#141breaking change: email validation now usesemail-validator#142v0.7.1 (2018-02-07)fix bug withcreate_modelmodifying the base classv0.7.0 (2018-02-06)added compatibility with abstract base classes (ABCs)#123addcreate_modelmethod#113#125breaking change: rename.configto.__config__on a modelbreaking change: remove deprecated.values()on a model, use.dict()insteadremove use ofOrderedDictand use simple dict#126addConfig.use_enum_values#127add wildcard validators of the form@validate('*')#128v0.6.4 (2018-02-01)allow python date and times objects#122v0.6.3 (2017-11-26)fix direct install withoutREADME.rstpresentv0.6.2 (2017-11-13)errors for invalid validator usesafer check for complex models inSettingsv0.6.1 (2017-11-08)prevent duplicate validators,#101addalwayskwarg to validators,#102v0.6.0 (2017-11-07)assignment validation#94, thanks petroswork!JSON in environment variables for complex types,#96addvalidatordecorators for complex validation,#97depreciatevalues(...)and replace with.dict(...),#99v0.5.0 (2017-10-23)addUUIDvalidation#89removeindexandtrackfrom error object (json) if they're null#90improve the error text when a list is provided rather than a dict#90add benchmarks table to docs#91v0.4.0 (2017-07-08)show length in string validation errorfix aliases in config during inheritance#55simplify error displayuse unicode ellipsis intruncateaddparse_obj,parse_rawandparse_filehelper functions#58switch annotation only fields to come first in fields list not lastv0.3.0 (2017-06-21)immutable models viaconfig.allow_mutation = False, associated cleanup and performance improvement#44immutable helper methodsconstruct()andcopy()#53allow pickling of models#53setattris removed as__setattr__is now intelligent#44raise_exceptionremoved, Models now always raise exceptions#44instance method validators removeddjango-restful-framework benchmarks added#47fix inheritance bug#49make str type stricter so list, dict etc are not coerced to strings.#52addStrictStrwhich only always strings as input#52v0.2.1 (2017-06-07)pypi and travis together messed up the deploy ofv0.2this should fix itv0.2.0 (2017-06-07)breaking change:values()on a model is now a method not a property,
takesincludeandexcludeargumentsallow annotation only fields to support mypyadd prettyto_string(pretty=True)method for modelsv0.1.0 (2017-06-03)add docsadd history