Dataclass or BaseModel

Pydantic’s documentation primarily adopts the BaseModel approach, i.e.

from pydantic import BaseModel

class Item(BaseModel):

rather than the dataclass approach,

from pydantic.dataclasses import dataclass

class Item:

and whilst Quart-Schema supports both this documentation primarily adopts the dataclass approach. This is because I find this approach to be cleaner and clearer. I think if pydantic had started when after dataclass was added to the Python stdlib it would have done the same.


Just a caveat, that these two approaches lead to potentially subtle differences which you can read about here.