mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
Extend dataclass doc (#848)
* Add note detailing dataclass vs BaseModel usage * Add changes rst describing the change
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Update documentation to specify the use of ``pydantic.dataclasses.dataclass`` and subclassing ``pydantic.BaseModel``.
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user