In some projects, I use pydantic.dataclasses to add validation to dataclass models.
This is useful on project that requires dataclasses but still want to use pydantic for validation. All fields and type annotation of pydantic are compatible and can be generated in the same way.
We could easily support this as there is only 2 changes with pydantic.BaseModel:
from pydantic import BaseModel
class MyModel(BaseModel):
id: str
to
from pydantic.dataclasses import dataclass
@dataclass
class MyModel:
id: str
@dataclass
class MyModel:
id: str
description: str = None # This field needs to be after id field
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too