Extend dataclass doc (#848)

* Add note detailing dataclass vs BaseModel usage

* Add changes rst describing the change
This commit is contained in:
Matthias
2019-10-01 16:51:37 +02:00
committed by Samuel Colvin
parent 12f4e0d082
commit 3ce16edbe2
2 changed files with 8 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
Update documentation to specify the use of ``pydantic.dataclasses.dataclass`` and subclassing ``pydantic.BaseModel``.
+7
View File
@@ -136,6 +136,13 @@ Dataclasses work in python 3.6 using the `dataclasses backport package <https://
(This script is complete, it should run "as is")
.. note::
Keep in mind that ``pydantic.dataclasses.dataclass`` is a drop in replacement for ``dataclasses.dataclass``
with validation, not a repacement for ``pydantic.BaseModel``. There are cases where subclassing
``pydantic.BaseModel`` is the better choice. For more information and disucssion see
`samuelcolvin/pydantic#6239 <https://github.com/samuelcolvin/pydantic/issues/710>`_.
You can use all the standard pydantic field types and the resulting dataclass will be identical to the one
created by the standard library ``dataclass`` decorator.