Open MeltyBot opened 3 years ago
+1
Pydantic is way more friendly towards static type analysis via mypy/pyright and cuts down drastically on "stupid" type errors at scale and/or when running in prod
There's a draft MR on GitLab that unfortunately never came through but could serve as inspiration for folks interested in contributing: https://gitlab.com/meltano/sdk/-/merge_requests/84
Migrated from GitLab: https://gitlab.com/meltano/sdk/-/issues/110
Originally created by @edgarrmondragon on 2021-04-20 22:19:33
Pydantic is the most popular data validation and serialization library for Python at the moment. It is used by the new-ish and increasingly popular web framework FastAPI and by other frameworks wanting to support reliable data validation and serialization (like odmantic for MongoDB and pydantic-sqlalchemy).
Alternatives include mashumaro, marshmallow and dataclasses-json. All of these support only a subset of Pydantic's features (no validation, serialization but no deserialization).
I propose leveraging Pydantic to allow the SDK user to define a plugin's configuration and inline stream schemas using a known, powerful and well-documented library. The implementation would look something like the following:
Notes:
BaseSchema
needs to extend pydantic to make sure schemas are Singer-compatible: https://pydantic-docs.helpmanual.io/usage/schema/#schema-customization