2 ms·
Type hints alone don't do this, but you can use Pydantic to accomplish what you want. In Python type hints aren't enforced anywhere at runtime. They're for a ty
by Spivak 2y ago
Type hints alone don't do this, but you can use Pydantic to accomplish what you want. In Python type hints aren't enforced anywhere at runtime. They're for a type-checker to validate your source.
https://docs.pydantic.dev/latest/concepts/validation_decorator/ https://docs.pydantic.dev/latest/concepts/validation_decorat...