Why do I get “AttributeError: __fields_set__” when subclassing a Pydantic BaseModel?

You need to decide whether to inherit from pydantic.BaseModel, or whether to use the @dataclass decorator (either from dataclasses, or from pydantic.dataclasses).

Either is fine, but you cannot use both, according to the documentation (bold face added by myself):

If you don’t want to use pydantic’s BaseModel you can instead get the same data validation on standard dataclasses

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)