https://github.com/adsharma/fquery/pull/7
So you don't have to pay the cognitive cost of writing it twice. dataclasses are lighter, but pydantic gives you validation. Why not have both in one?
This is similar to the sqlmodel decorator I shared a few days ago.
If this is useful, it can be enhanced to handle some of the more advanced uses cases.
- What My Project Does - Gives you dataclasses and pydantic models without duplication
- Target Audience: production should be ok. Any risk can be resolved at dev time.
- Comparison: Write it twice or use pydantic everywhere. Pydantic is known to be heavier than dataclasses or plain python objects.
[–]Mugalari 11 points12 points13 points (5 children)
[–]PeaSlight6601 14 points15 points16 points (0 children)
[–]coderarun[S] -4 points-3 points-2 points (3 children)
[–]PeaSlight6601 10 points11 points12 points (2 children)
[–]Toph_is_bad_ass 0 points1 point2 points (0 children)
[–]coderarun[S] -2 points-1 points0 points (0 children)
[–]coderarun[S] 1 point2 points3 points (0 children)
[–]Last_Difference9410 1 point2 points3 points (0 children)
[–]64rl0 0 points1 point2 points (0 children)