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.3.tar.gz
(5.9 kB
view hashes)
Built Distribution
Close
Hashes for pydantic_avro-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb63b01c30ff230b7f7bdb0b28a8a5de800e20b9c10d1d666dd8ddf91654b020 |
|
MD5 | 0ba13255a885ec695772445d92ed7d32 |
|
BLAKE2b-256 | b5610ea6e5a5f626b16cee2260d150520693f2e65bc07f5608d3b94f0ecdb03d |