Pydantic is a neat package that's used heavily in some libraries that we like, such as FastAPI.
Snippet from pydantic's docs:
Data validation and settings management using python type annotations. pydantic enforces type hints at runtime, and provides user friendly errors when data is invalid. Define how data should be in pure, canonical python; validate it with pydantic.
There are alternatives, such as attrs. Also used by libraries we like, such as pytest. And one of the committers of attrs explains why they prefer it instead in this nice blogpost