Skip to main content

Converting pydantic classes to avro schemas

Project description

Python package codecov PyPI version CodeQL

pydantic-avro

This library can convert a pydantic class to a avro schema or generate python code from a avro schema.

Install

pip install pydantic-avro

Pydantic class to avro schema

import json
from typing import Optional

from pydantic_avro.base import AvroBase

class TestModel(AvroBase):
    key1: str
    key2: int
    key2: Optional[str]

schema_dict: dict = TestModel.avro_schema()
print(json.dumps(schema_dict))

Avro schema to pydantic

# Print to stdout
pydantic-avro avro_to_pydantic --asvc /path/to/schema.asvc

# Save it to a file
pydantic-avro avro_to_pydantic --asvc /path/to/schema.asvc --output /path/to/output.py

Install for developers

Install package
  • Requirement: Poetry 1.*
poetry install
Run unit tests
pytest
coverage run -m pytest  # with coverage
# or (depends on your local env) 
poetry run pytest
poetry run coverage run -m pytest  # with coverage
Run linting

The linting is checked in the github workflow. To fix and review issues run this:

black .   # Auto fix all issues
isort .   # Auto fix all issues
pflake .  # Only display issues, fixing is manual

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic-avro-0.4.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

pydantic_avro-0.4.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file pydantic-avro-0.4.1.tar.gz.

File metadata

  • Download URL: pydantic-avro-0.4.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.1 Darwin/20.6.0

File hashes

Hashes for pydantic-avro-0.4.1.tar.gz
Algorithm Hash digest
SHA256 99de4b65550f5042a169e81d09686a7785e62d954804db4ba5d74f3acc2ba9d2
MD5 fbc560816d963e6567235b601837db32
BLAKE2b-256 f092271c51b799933d284f2e6c4c0d6e3fd238f961485d00bd96a9f232e04b66

See more details on using hashes here.

File details

Details for the file pydantic_avro-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: pydantic_avro-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.1 Darwin/20.6.0

File hashes

Hashes for pydantic_avro-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cd650e518078b92c05aaceec231bdc23f8b5f9a517a12bfe4467f13ffaec41da
MD5 0d2307250aca8af2bf9fd019c92397cd
BLAKE2b-256 ff96687b117761fa9ee091006a564f253f1093dfd3e4d3a616454402e434043f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page