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.

Installation

pip install pavlova

Requirements

Pavlova is only supported on Python 3.6 and higher. With Python 3.6, it will install the dataclasses <https://github.com/ericvsmith/dataclasses> module. With Python 3.7 and higher, it will use the built-in dataclasses module.

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

Uploaded Source

Built Distribution

pavlova-0.1.1.dev1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pavlova-0.1.1.dev1.tar.gz
  • Upload date:
  • Size: 5.0 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.6.3

File hashes

Hashes for pavlova-0.1.1.dev1.tar.gz
Algorithm Hash digest
SHA256 7b3c375c0b72fbeb88ac898c24a11667bb5caa524b5b9176caf00e64d8cd81e8
MD5 150e58a446ea57b8172ed8d267b09a4a
BLAKE2b-256 b051b30c6b0bb5c3d1b40c031659630af9ffaeb2facaf4d812bf40ed2fc9caf7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pavlova-0.1.1.dev1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 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.6.3

File hashes

Hashes for pavlova-0.1.1.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 add08eba058ebfc8a705f2a7419f747240ed51761dd1a7712faab59386d1268c
MD5 08fd007aec1c4ee5e55fbad0dff11005
BLAKE2b-256 4a0ea428bbf97b9ce9b7766f632baa0940929413ea1ec9143ea06fd696daad69

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