Changelog History
Page 1
-
v1.7.3 Changes
November 30, 2020👀 See Changelog.
Thank you to pydantic's sponsors:
@timdrijvers, @BCarley, @chdsbd, @tiangolo, @matin, @linusg, @kevinalh, @jorgecarleitao, @koxudaxi, @primer-api,
👍 @mkeen, @meadsteve for their kind support.- 🛠 fix: set right default value for required (optional) fields, #2142 by @PrettyWood
- fix: support
underscore_attrs_are_private
with generic models, #2138 by @PrettyWood - fix: update all modified field values in
root_validator
whenvalidate_assignment
is on, #2116 by @PrettyWood - 👍 Allow pickling of
pydantic.dataclasses.dataclass
dynamically created from a built-indataclasses.dataclass
, #2111 by @aimestereo - 🛠 Fix a regression where Enum fields would not propagate keyword arguments to the schema, #2109 by @bm424
- Ignore
__doc__
as private attribute whenConfig.underscore_attrs_are_private
is set, #2090 by @PrettyWood
-
v1.7.2 Changes
November 01, 2020👀 See Changelog.
Thank you to pydantic's sponsors:
@timdrijvers, @BCarley, @chdsbd, @tiangolo, @matin, @linusg, @kevinalh, @jorgecarleitao, @koxudaxi, @primer-api, @mkeen
👍 for their kind support.- 🛠 fix slow
GenericModel
concrete model creation, allowGenericModel
concrete name reusing in module, #2078 by @MrMrRobat - keep the order of the fields when
validate_assignment
is set, #2073 by @PrettyWood - forward all the params of the stdlib
dataclass
when converted into pydanticdataclass
, #2065 by @PrettyWood
- 🛠 fix slow
-
v1.7.1 Changes
October 28, 2020👀 See Changelog.
Thank you to pydantic's sponsors:
@timdrijvers, @BCarley, @chdsbd, @tiangolo, @matin, @linusg, @kevinalh, @jorgecarleitao, @koxudaxi, @primer-api, @mkeen
👍 for their kind support.- 🛠 fix annotation of
validate_arguments
when passing configuration as argument, #2055 by @layday - 🛠 Fix mypy assignment error when using
PrivateAttr
, #2048 by @aphedges - fix
underscore_attrs_are_private
causingTypeError
when overriding__init__
, #2047 by @samuelcolvin - 🛠 Fixed regression introduced in v1.7 involving exception handling in field validators when
validate_assignment=True
, #2044 by @johnsabath - fix: pydantic
dataclass
can inherit from stdlibdataclass
andConfig.arbitrary_types_allowed
is supported, #2042 by @PrettyWood
- 🛠 fix annotation of
-
v1.7 Changes
October 26, 2020👀 See Changelog.
Thank you to pydantic's sponsors:
@timdrijvers, @BCarley, @chdsbd, @tiangolo, @matin, @linusg, @kevinalh, @jorgecarleitao, @koxudaxi, @primer-api
👍 for their kind support.Highlights
- 👍 python 3.9 support, thanks @PrettyWood
- 📄 Private model attributes, thanks @MrMrRobat
- 📄 "secrets files" support in
BaseSettings
, thanks @mdgilene - 📄 convert stdlib dataclasses to pydantic dataclasses and use stdlib dataclasses in models, thanks @PrettyWood
🔄 Changes
- 💥 Breaking Change: remove
__field_defaults__
, adddefault_factory
support withBaseModel.construct
.
0️⃣ Use.get_default()
method on fields in__fields__
attribute instead, #1732 by @PrettyWood - 👕 Rearrange CI to run linting as a separate job, split install recipes for different tasks, #2020 by @samuelcolvin
- 👍 Allows 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, #2005 by @choogeboom - Call validator with the correct
values
parameter type inBaseModel. __setattr__
,
whenvalidate_assignment = True
in model config, #1999 by @me-ransh - 👮 Force
fields.Undefined
to be a singleton object, fixing inherited generic model schemas, #1981 by @daviskirk - ✅ Include tests in source distributions, #1976 by @sbraz
- Add ability to use
min_length/max_length
constraints with secret types, #1974 by @uriyyo - Also check
root_validators
whenvalidate_assignment
is on, #1971 by @PrettyWood - 🛠 Fix const validators not running when custom validators are present, #1957 by @hmvp
- ➕ add
deque
to field types, #1935 by @wozniakty - ➕ add basic support for python 3.9, #1832 by @PrettyWood
- 🛠 Fix typo in the anchor of exporting_models.md#modelcopy and incorrect description, #1821 by @KimMachineGun
- ➕ Added ability for
BaseSettings
to read "secret files", #1820 by @mdgilene - add
parse_raw_as
utility function, #1812 by @PrettyWood - 👌 Support home directory relative paths for
dotenv
files (e.g.~/.env
), #1803 by @PrettyWood - 📚 Clarify documentation for
parse_file
to show that the argument
should be a file path not a file-like object, #1794 by @mdavis-xyz - 🛠 Fix false positive from mypy plugin when a class nested within a
BaseModel
is namedModel
, #1770 by @selimb - ➕ add basic support of Pattern type in schema generation, #1767 by @PrettyWood
- 👌 Support custom title, description and default in schema of enums, #1748 by @PrettyWood
- Properly represent
Literal
Enums whenuse_enum_values
is True, #1747 by @noelevans - 👍 Allows timezone information to be added to strings to be formatted as time objects. Permitted formats are
Z
for UTC
or an offset for absolute positive or negative time shifts. Or the timezone data can be omitted, #1744 by @noelevans - Add stub
__init__
with python 3.6 signature forForwardRef
, #1738 by @SirTelemak - 🛠 Fix behaviour with forward refs and optional fields in nested models, #1736 by @PrettyWood
- ➕ add
Enum
andIntEnum
as valid types for fields, #1735 by @PrettyWood - Change default value of
__module__
argument ofcreate_model
fromNone
to'pydantic.main'
.
Set reference of created concrete model to it's module to allow pickling (not applied to models created in
functions), #1686 by @MrMrRobat - ➕ Add private attributes support, #1679 by @MrMrRobat
- ➕ add
config
to@validate_arguments
, #1663 by @samuelcolvin - 👍 Allow descendant Settings models to override env variable names for the fields defined in parent Settings models with
🔧env
in theirConfig
. Previously onlyenv_prefix
configuration option was applicable, #1561 by @ojomio - 👌 Support
ref_template
when creating schema$ref
s, #1479 by @Kilo59 - Add a
__call__
stub toPyObject
so that mypy will know that it is callable, #1352 by @brianmaissy - 👍
pydantic.dataclasses.dataclass
decorator now supports built-indataclasses.dataclass
.
It is hence possible to convert an existingdataclass
easily to add pydantic validation.
👍 Moreover nested dataclasses are also supported, #744 by @PrettyWood
-
v1.6.1 Changes
July 15, 2020👀 See Changelog.
👍 Thank you to pydantic's sponsors: @matin, @tiangolo, @chdsbd, @jorgecarleitao, and 1 anonymous sponsor for their kind support.
🔄 changes:
- 🛠 fix validation and parsing of nested models with
default_factory
, #1710 by @PrettyWood
- 🛠 fix validation and parsing of nested models with
-
v1.6 Changes
July 11, 2020👀 See Changelog.
👍 Thank you to pydantic's sponsors: @matin, @tiangolo, @chdsbd, @jorgecarleitao, and 1 anonymous sponsor for their kind support.
🔄 changes:
- Modify validators for
conlist
andconset
to not havealways=True
, #1682 by @samuelcolvin - ➕ add port check to
AnyUrl
(can't exceed 65536) ports are 16 insigned bits:0 <= port <= 2**16-1
src: rfc793 header format, #1654 by @flapili - 0️⃣ Document default
regex
anchoring semantics, #1648 by @yurikhan - Use
chain.from_iterable
in 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, #1642 by @cool-RR - ➕ Add
conset()
, analogous toconlist()
, #1623 by @patrickkwang - make pydantic errors (un)pickable, #1616 by @PrettyWood
- 👍 Allow custom encoding for
dotenv
files, #1615 by @PrettyWood - Ensure
SchemaExtraCallable
is always defined to get type hints on BaseConfig, #1614 by @PrettyWood - ⚡️ Update datetime parser to support negative timestamps, #1600 by @mlbiche
- ⚡️ Update mypy, remove
AnyType
alias forType[Any]
, #1598 by @samuelcolvin - Adjust handling of root validators so that errors are aggregated from all failing root validators, instead of reporting on only the first root validator to fail, #1586 by @beezee
- Make
__modify_schema__
on Enums apply to the enum schema rather than fields that use the enum, #1581 by @therefromhere - Fix behavior of
__all__
key when used in conjunction with index keys in advanced include/exclude of fields that are sequences, #1579 by @xspirus - 📄 Subclass validators do not run when referencing a
List
field defined in a parent class wheneach_item=True
. Added an example to the docs illustrating this, #1566 by @samueldeklund - change
schema.field_class_to_schema
to supportfrozenset
in schema, #1557 by @wangpeibao - Call
__modify_schema__
only for the field schema, #1552 by @PrettyWood - 🚚 Move the assignment of
field.validate_always
infields.py
so thealways
parameter of validators work on inheritance, #1545 by @dcHHH - ➕ Added support for UUID instantiation through 16 byte strings such as
b'\x12\x34\x56\x78' * 4
. This was done to supportBINARY(16)
columns in sqlalchemy, #1541 by @shawnwall - ➕ Add a test assertion that
default_factory
can return a singleton, #1523 by @therefromhere - Add
NameEmail. __eq__
so duplicateNameEmail
instances are evaluated as equal, #1514 by @stephen-bunn - ➕ Add datamodel-code-generator link in pydantic document site, #1500 by @koxudaxi
- ➕ Added a "Discussion of Pydantic" section to the documentation, with a link to "Pydantic Introduction" video by Alexander Hultnér, #1499 by @Hultner
- 0️⃣ Avoid some side effects of
default_factory
by calling it only once
0️⃣ if possible and by not setting a default value in the schema, #1491 by @PrettyWood - ➕ Added docs about dumping dataclasses to JSON, #1487 by @mikegrima
- Make
BaseModel. __signature__
class-only, so getting__signature__
from model instance will raiseAttributeError
, #1466 by @MrMrRobat - include
'format': 'password'
in the schema for secret types, #1424 by @Atheuz - Modify schema constraints on
ConstrainedFloat
so thatexclusiveMinimum
and
minimum are not included in the schema if they are equal to-math.inf
and
exclusiveMaximum
andmaximum
are not included if they are equal tomath.inf
, #1417 by @vdwees - Squash internal
__root__
dicts in.dict()
(and, by extension, in.json()
), #1414 by @patrickkwang - 🚚 Move
const
validator to post-validators so it validates the parsed value, #1410 by @selimb - 🛠 Fix model validation to handle nested literals, e.g.
Literal['foo', Literal['bar']]
, #1364 by @DBCerigo - ✂ Remove
user_required = True
fromRedisDsn
, neither user nor password are required, #1275 by @samuelcolvin - ✂ Remove extra
allOf
from schema for fields withUnion
and customField
, #1209 by @mostaphaRoudsari - ⚡️ Updates OpenAPI schema generation to output all enums as separate models.
Instead of inlining the enum values in the model schema, models now use a$ref
property to point to the enum definition, #1173 by @calvinwyoung
- Modify validators for
-
v1.5.1 Changes
April 23, 2020👀 See Changelog.
- Signature generation with
extra: allow
never uses a field name, #1418 by @PrettyWood - 0️⃣ Avoid mutating
Field
default value, #1412 by @PrettyWood
- Signature generation with
-
v1.5 Changes
April 18, 2020👀 See Changelog.
- 👉 Make includes/excludes arguments for
.dict()
,._iter()
, ..., immutable, #1404 by @AlexECX - Always use a field's real name with includes/excludes in
model._iter()
, regardless ofby_alias
, #1397 by @AlexECX - ⚡️ Update constr regex example to include start and end lines, #1396 by @lmcnearney
- Confirm that shallow
model.copy()
does make a shallow copy of attributes, #1383 by @samuelcolvin - Renaming
model_name
argument ofmain.create_model()
to__model_name
to allow usingmodel_name
as a field name, #1367 by @kittipatv - 🔌 Replace raising of exception to silent passing for non-Var attributes in mypy plugin, #1345 by @b0g3r
- ✂ Remove
typing_extensions
dependency for python 3.8, #1342 by @PrettyWood - 👉 Make
SecretStr
andSecretBytes
initialization idempotent, #1330 by @Atheuz - document making secret types dumpable using the json method, #1328 by @Atheuz
- 🍎 Move all testing and build to github actions, add windows and macos binaries,
thank you @StephenBrown2 for much help, #1326 by @samuelcolvin - 🛠 fix card number length check in
PaymentCardNumber
,PaymentCardBrand
now inherits fromstr
, #1317 by @samuelcolvin - Have
BaseModel
inherit fromRepresentation
to make mypy happy when overriding__str__
, #1310 by @FuegoFro - 👍 Allow
None
as input to all optional list fields, #1307 by @PrettyWood - ➕ Add
datetime
field todefault_factory
example, #1301 by @StephenBrown2 - 👍 Allow subclasses of known types to be encoded with superclass encoder, #1291 by @StephenBrown2
- Exclude exported fields from all elements of a list/tuple of submodels/dicts with
' __all__'
, #1286 by @masalim2 - ➕ Add pydantic.color.Color objects as available input for Color fields, #1258 by @leosussan
- In examples, type nullable fields as
Optional
, so that these are valid mypy annotations, #1248 by @kokes - Make
pattern_validator()
accept pre-compiledPattern
objects. Fixstr_validator()
return type tostr
, #1237 by @adamgreg - Document how to manage Generics and inheritance, #1229 by @Esadruhn
update_forward_refs()
method of BaseModel now copies__dict__
of class module instead of modyfying it, #1228 by @Paul-Ilyin- 👌 Support instance methods and class methods with
@validate_arguments
, #1222 by @samuelcolvin - ➕ Add
default_factory
argument toField
to create a dynamic default value by passing a zero-argument callable, #1210 by @PrettyWood - ➕ add support for
NewType
ofList
,Optional
, etc, #1207 by @Kazy - 🛠 fix mypy signature for
root_validator
, #1192 by @samuelcolvin - 🛠 Fixed parsing of nested 'custom root type' models, #1190 by @Shados
- ➕ Add
validate_arguments
function decorator which checks the arguments to a function matches type annotations, #1179 by @samuelcolvin - Add
__signature__
to models, #1034 by @MrMrRobat - 🔨 Refactor
._iter()
method, 10x speed boost fordict(model)
, #1017 by @MrMrRobat
- 👉 Make includes/excludes arguments for
-
v1.4 Changes
January 24, 2020👀 See Changelog.
- 💥 Breaking Change: alias precedence logic changed so aliases on a field always take priority over
an alias fromalias_generator
to avoid buggy/unexpected behaviour,
👀 see here for details, #1178 by @samuelcolvin - ➕ Add support for unicode and punycode in TLDs, #1182 by @jamescurtin
- 🛠 Fix
cls
argument in validators during assignment, #1172 by @samuelcolvin - completing Luhn algorithm for
PaymentCardNumber
, #1166 by @cuencandres - add support for generics that implement
__get_validators__
like a custom data type, #1159 by @tiangolo - ➕ add support for infinite generators with
Iterable
, #1152 by @tiangolo - 🛠 fix
url_regex
to accept schemas with+
,-
and.
after the first character, #1142 by @samuelcolvin - 🚚 move
version_info()
toversion.py
, suggest its use in issues, #1138 by @samuelcolvin - 👌 Improve pydantic import time by roughly 50% by deferring some module loading and regex compilation, #1127 by @samuelcolvin
- 🛠 Fix
EmailStr
andNameEmail
to accept instances of themselves in cython, #1126 by @koxudaxi - Pass model class to the
Config.schema_extra
callable, #1125 by @therefromhere - 🛠 Fix regex for username and password in URLs, #1115 by @samuelcolvin
- ➕ Add support for nested generic models, #1104 by @dmontagu
- add
__all__
to__init__.py
to prevent "implicit reexport" errors from mypy, #1072 by @samuelcolvin - ➕ Add support for using "dotenv" files with
BaseSettings
, #1011 by @acnebs
- 💥 Breaking Change: alias precedence logic changed so aliases on a field always take priority over
-
v1.3 Changes
December 21, 2019👀 See Changelog.
- Change
schema
andschema_model
to handle dataclasses by using their__pydantic_model__
feature, #792 by @aviramha - Added option for
root_validator
to be skipped if values validation fails using keywordskip_on_failure=True
, #1049 by @aviramha - 👍 Allow
Config.schema_extra
to be a callable so that the generated schema can be post-processed, #1054 by @selimb - ⚡️ Update mypy to version 0.750, #1057 by @dmontagu
- Trick Cython into allowing str subclassing, #1061 by @skewty
- Prevent type attributes being added to schema unless the attribute
__schema_attributes__
isTrue
, #1064 by @samuelcolvin - Change
BaseModel.parse_file
to useConfig.json_loads
, #1067 by @kierandarcy - 🛠 Fix for optional
Json
fields, #1073 by @volker48 - 🔄 Change the default number of threads used when compiling with cython to one,
👍 allow override via theCYTHON_NTHREADS
environment variable, #1074 by @samuelcolvin - 👷 Run FastAPI tests during Pydantic's CI tests, #1075 by @tiangolo
- My mypy strictness constraints, and associated tweaks to type annotations, #1077 by @samuelcolvin
- Add
__eq__
to SecretStr and SecretBytes to allow "value equals", #1079 by @sbv-trueenergy - 🛠 Fix schema generation for nested None case, #1088 by @lutostag
- Consistent checks for sequence like objects, #1090 by @samuelcolvin
- 🛠 Fix
Config
inheritance onBaseSettings
when used withenv_prefix
, #1091 by @samuelcolvin - Fix for
__modify_schema__
when it conflicted withfield_class_to_schema*
, #1102 by @samuelcolvin - 📄 docs: Fix explanation of case sensitive environment variable names when populating
BaseSettings
subclass attributes, #1105 by @tribals - 📚 Rename django-rest-framework benchmark in documentation, #1119 by @frankie567
- Change