Skip to main content

Simplified deserialization using dataclasses

Project description

pavlova is a library that assists in mapping an unknown input into a dataclass.

from datetime import datetime
from dataclasses import dataclass

from pavlova import Pavlova


@dataclass
class Input:
    id: int
    name: str
    date: datetime


Pavlova().from_mapping({
    'id': 10,
    'name': 100
    'date': '2018-08-10',
}, Input)
# Input(id=10, name='100', date=datetime.datetime(2018, 8, 10, 0, 0))

Pavlova was born out of frustration with the lack of typing support for existing deserialization libraries. With the introduction of dataclasses in Python 3.7, they seemed like the perfect use for defining a deserialization schema.

Supported functionality

Parsing of booleans, datetimes, floats, ints, strings, decimals, dictionaries, enums, lists are currently supported.

There are more parsers to come, however to implement your own custom parser, simply implement PavlovaParser in pavlova.parsers, and register it with the Pavlova object with the register_parser method.

License

GNU LGPLv3. Please see LICENSE and COPYING.LESSER.

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

pavlova-0.1.1.dev0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

pavlova-0.1.1.dev0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file pavlova-0.1.1.dev0.tar.gz.

File metadata

  • Download URL: pavlova-0.1.1.dev0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for pavlova-0.1.1.dev0.tar.gz
Algorithm Hash digest
SHA256 5c5e3370452e6cb8bcdd941c8f6597259e6a93402eedd5863b0f73094bb050cc
MD5 e8b1163921be8de1b73ebb2c9bc0e08c
BLAKE2b-256 d4becb49b26c6335e70f67f64427d9a04286b778d33a15c8197255e5506627e3

See more details on using hashes here.

File details

Details for the file pavlova-0.1.1.dev0-py3-none-any.whl.

File metadata

  • Download URL: pavlova-0.1.1.dev0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for pavlova-0.1.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 9581950db0c167de7b02f74265547b6fe50e9b43817a7726c090de2110701296
MD5 18c1528fc035b0892e7b5c4b9dcf505e
BLAKE2b-256 e2a770b5500630355a4cbe2778d3c710c30d614b2ee1849e58abe873d3c4ce70

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