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

I love pydantic and use it whenever I can, but that decorator seems a bit misguided, no? It requires type hints anyway, by which point mypy would catch issues with types mismatches statically, before runtime. That would seem strictly more useful. Maybe I’m missing an aspect of what the decorator solves though.


Mypy is an amazing, should have mentioned it.

Pydantic enforces types when you're working with a Pydantic objects. However, it doesn't help with functions that accept vanilla types as parameters. validate arguments checks that the callers parameters matches the function's type hints.

This is helpful because a static analyzer like mypy won't catch the wrong type being passed in all situations.




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

Search: