v1.10.0a1 (2022-08-22)
Pre-release
Pre-release
Docs for this pre-release are available here!
- Refactor the whole pydantic
dataclassdecorator to really act like its standard lib equivalent.
It hence keeps__eq__,__hash__, ... and makes comparison with its non-validated version possible.
It also fixes usage offrozendataclasses in fields and usage ofdefault_factoryin nested dataclasses.
The support ofConfig.extrahas been added.
Finally, config customization directly via adictis now possible, #2557 by @PrettyWood
BREAKING CHANGES:- The
compiledboolean (whether pydantic is compiled with cython) has been moved frommain.pytoversion.py - Now that
Config.extrais supported,dataclassignores by default extra arguments (likeBaseModel)
- The
- Fix PEP487
__set_name__protocol inBaseModelfor PrivateAttrs, #4407 by @tlambert03 - Rename
mastertomain, #4405 by @hramezani - Fix
StrictStrdoes not raiseValidationErrorwhenmax_lengthis present inField, #4388 by @hramezani - Make
SecretStrandSecretByteshashable, #4387 by @chbndrhnns - Fix
StrictBytesdoes not raiseValidationErrorwhenmax_lengthis present inField, #4380 by @JeanArhancet - Add support for bare
type, #4375 by @hramezani - Support Python 3.11, including binaries for 3.11 in PyPI, #4374 by @samuelcolvin
- Add support for
re.Pattern, #4366 by @hramezani - Fix
__post_init_post_parse__is incorrectly passed keyword arguments when no__post_init__is defined, #4361 by @hramezani - Fix implicitly importing
ForwardRefandCallablefrompydantic.typinginstead oftypingand also exposeMappingIntStrAny, #4358 by @aminalaee - remove
Anytypes from thedataclassdecorator so it can be used with thedisallow_any_exprmypy option, #4356 by @DetachHead - moved repo to
pydantic/pydantic, #4348 by @yezz123 - fix "extra fields not permitted" error when dataclass with
Extra.forbidis validated multiple times, #4343 by @DetachHead - Add Python 3.9 and 3.10 examples to docs, #4339 by @Bobronium
- Discriminated union models now use
oneOfinstead ofanyOfwhen generating OpenAPI schema definitions, #4335 by @MaxwellPayne - Allow type checkers to infer inner type of
Jsontype.Json[list[str]]will be now inferred aslist[str],
Json[Any]should be used instead of plainJson.
Runtime behaviour is not changed, #4332 by @Bobronium - Allow empty string aliases by using a
alias is not Nonecheck, rather thanbool(alias), #4253 by @SergeyTsaplin - Update
ForwardRefs inField.outer_type_, #4249 by @JacobHayes - The use of
__dataclass_transform__has been replaced bytyping_extensions.dataclass_transform, which is the preferred way to mark pydantic models as a dataclass under PEP 681, #4241 by @multimeric - Use parent model's
Configwhen validating nestedNamedTuplefields, #4219 by @synek - Update
BaseModel.constructto work with aliased Fields, #4192 by @kylebamos - Catch certain raised errors in
smart_deepcopyand revert todeepcopyif so, #4184 by @coneybeare - Add
Config.anystr_upperandto_upperkwarg to constr and conbytes, #4165 by @satheler - Fix JSON schema for
setandfrozensetwhen they include default values, #4155 by @aminalaee - Teach the mypy plugin that methods decorated by
@validatorare classmethods, #4102 by @DMRobertson - Improve mypy plugin's ability to detect required fields, #4086 by @richardxia
- Support fields of type
Type[]in schema, #4051 by @aminalaee - Add
defaultvalue in JSON Schema whenconst=True, #4031 by @aminalaee - Adds reserved word check to signature generation logic, #4011 by @strue36
- Fix Json strategy failure for the complex nested field, #4005 by @SergioSim
- Add JSON-compatible float constraint
allow_inf_nan, #3994 by @tiangolo - Remove undefined behaviour when
env_prefixhad characters in common withenv_nested_delimiter, #3975 by @arsenron - Support generics model with
create_model, #3945 by @hot123s - allow submodels to overwrite extra field info, #3934 by @PrettyWood
- Document and test structural pattern matching (PEP 636) on
BaseModel, #3920 by @irgolic - Fix incorrect deserialization of python timedelta object to ISO 8601 for negative time deltas.
Minus was serialized in incorrect place ("P-1DT23H59M59.888735S" instead of correct "-P1DT23H59M59.888735S"), #3899 by @07pepa - Fix validation of discriminated union fields with an alias when passing a model instance, #3846 by @chornsby
- Add a CockroachDsn type to validate CockroachDB connection strings. The type
supports the following schemes:cockroachdb,cockroachdb+psycopg2andcockroachdb+asyncpg, #3839 by @blubber - Fix MyPy plugin to not override pre-existing
__init__method in models, #3824 by @patrick91 - Fix mypy version checking, #3783 by @KotlinIsland
- support overwriting dunder attributes of
BaseModelinstances, #3777 by @PrettyWood - Added
ConstrainedDateandcondate, #3740 by @hottwaj - Support
kw_onlyin dataclasses, #3670 by @DetachHead - Add comparison method for
Colorclass, #3646 by @aminalaee - Drop support for python3.6, associated cleanup, #3605 by @samuelcolvin
- created new function
to_lower_camel()for "non pascal case" camel case, #3463 by @schlerp - Add checks to
defaultanddefault_factoryarguments in Mypy plugin, #3430 by @klaa97 - fix mangling of
inspect.signatureforBaseModel, #3413 by @fix-inspect-signature - Adds the
SecretFieldabstract class so that all the current and future secret fields likeSecretStrandSecretByteswill derive from it, #3409 by @expobrain - Support multi hosts validation in
PostgresDsn, #3337 by @rglsk - Fix parsing of very small numeric timedelta values, #3315 by @samuelcolvin
- Update
SecretsSettingsSourceto respectconfig.case_sensitive, #3273 by @JeanArhancet - Add MongoDB network data source name (DSN) schema, #3229 by @snosratiershad
- Add support for multiple dotenv files, #3222 by @rekyungmin
- Raise an explicit
ConfigErrorwhen multiple fields are incorrectly set for a single validator, #3215 by @SunsetOrange - Allow ellipsis on
Fields insideAnnotatedforTypedDictsrequired, #3133 by @ezegomez - Catch overflow errors in
int_validator, #3112 by @ojii - Adds a
__rich_repr__ method to Representationclass which enables pretty printing with Rich, #3099 by @willmcgugan - Add percent encoding in
AnyUrland descendent types, #3061 by @FaresAhmedb validate_argumentsdecorator now supportsalias, #3019 by @MAD-py- Avoid
__dict__and__weakref__attributes inAnyUrland IP address fields, #2890 by @nuno-andre - Add ability to use
Finalin a field type annotation, #2766 by @uriyyo
Full Changelog: v1.9.0...v1.10a1