Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> what if I want to use a different kind of Mappable instead of a dict for something?

You can use custom field types either by using a `validator` with `pre=True` or a define a class with a `__get_validators__` classmethod.

But pydantic does have problems, imho it isn't strict enough & has given me the wrong types when using `Union`s a bunch of times. Defining custom encoding & decoding behavior is harder than it needs to be. The purely narrative documentation is easy to learn but difficult to reference.

I would agree that strict typing is unpythonic but in this case I think this is an outdated opinion of Python, one that it's been backpedaling on with type annotations &c. I think Python made perfectly reasonable decisions about this some 30 years ago, and they haven't aged well, which isn't even really a criticism as much as a consequence of it's enormous success. Python had outlived a lot of the ideas & attitudes about language design that went into making it, and carries them as scar tissue.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: