Converting pydantic classes to avro schemas
Project description
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
Release history Release notifications | RSS feed
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.2.tar.gz
(5.8 kB
view details)
Built Distribution
File details
Details for the file pydantic-avro-0.2.2.tar.gz
.
File metadata
- Download URL: pydantic-avro-0.2.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95d22d18dbc548113c561c8c1a1d1dff449a173f0740c914a414d9756d6293c4 |
|
MD5 | b8d484379f96657c253d7d822d4de2e3 |
|
BLAKE2b-256 | f7b8a00f6858dfb0d56531d5c715813de19c4266f889a23b7f4eacc0aa88633a |
File details
Details for the file pydantic_avro-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: pydantic_avro-0.2.2-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | fccb639af533f919114be75d769d894c5d095fc51d1f258f8d05a3a234e305c8 |
|
MD5 | a5beb88a48af011f39aa8c2699e39ec2 |
|
BLAKE2b-256 | 2f00ae98ad9759441bf167a41ac3c50d861ac4c865053abb47d28ba87545c810 |