Reasons to love Python: Validating Dataclasses (Part 1)
I love Python. Sure it’s not the fastest language in the world, and the package management can sometimes be painful, but I still love it.
I often reach for Python when developing the scripts that wrap systems together. Read a configuration file, process that data and do something with it.
I find myself reaching for a Pydantic BaseModel but I don’t want to create a virtualenv just for the script (uv script mode nonwithstanding), and so I just make it a dataclass and spend the next 20 minutes fighting type errors in my data.
What if there was a better way? What if I could re-implement just enough of a BaseModel in little enough code that I can just paste it into the script?