Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: (de)serialize using Pydantic #4973

Closed
wants to merge 5 commits into from
Closed

Conversation

Fokko
Copy link
Contributor

@Fokko Fokko commented Jun 6, 2022

https://github.com/samuelcolvin/pydantic provides data validation and settings management using Python type-hints.

Fast and extensible, pydantic plays nicely with your linters/IDE/brain. Define how data should be in pure, canonical Python 3.7+; validate it with pydantic.

I took the basis from @samredai's PR in #3677

It allows us to easily (de)serialize the TableMetadata including all the nested fields (schema, fields and types). While working on this, I've also noticed some discrepancies with the spec. For example:

  • Python uses is_optional, while the spec talks about required
  • The map.key is a field in Python, while in the spec, this is a type.
  • For the list, the element is a field in Python, while in the spec it is a type.

In this PR I also correct some of these discrapencies to avoid confusion among the different implementations. This PR comes with a lot of test to check proper (de)serialization of the tablemetadata, schema and types.

#3677

@github-actions github-actions bot added the python label Jun 6, 2022
@Fokko Fokko closed this Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants