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.2.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

pydantic_avro-0.2.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic-avro-0.2.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Darwin/20.6.0

File hashes

Hashes for pydantic-avro-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b3be4bbc37122adc13cbfcc4cf0eac451e6b141a06f181c3d8b6eb1bdcd23c50
MD5 2ce86dcb81d2a44ac3931f903b7099d5
BLAKE2b-256 fa94c42bfb008ed24cb6bea87d331792601d94e6629021af30af62ba7fcd7ce2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantic_avro-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Darwin/20.6.0

File hashes

Hashes for pydantic_avro-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03627b5913b94fdc847a59a1d1835f0c509a6a415c4e1467851a563bc7a3a2be
MD5 7a13aeecbcd90008533c99bf5a0a7cc6
BLAKE2b-256 8373fd10afc4c37133a9fe2c7ea234e1bfe3ac5ae8b82496036fc4e5d7400e15

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