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

Uploaded Source

Built Distribution

pavlova-0.1.1.dev3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pavlova-0.1.1.dev3.tar.gz
  • Upload date:
  • Size: 5.3 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.dev3.tar.gz
Algorithm Hash digest
SHA256 3ed362ca1ff035e48207e480989914f9cfc5246f1c2488ca9a9476e579cddad6
MD5 a29a12f15a356c8fb2126779f636cef0
BLAKE2b-256 3a40953ea467a38385c18db6747fdab4d53eecd2292ef7e2569cc0b31899d64c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pavlova-0.1.1.dev3-py3-none-any.whl
  • Upload date:
  • Size: 6.6 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.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 6ec828397f2797ca978d6efde25db5e0148e6b27aaca3cb798a4511dd5ab80e1
MD5 7302999f419cb3a500b029df58ad6ef4
BLAKE2b-256 d9792df2cd351240c9e74936933e048f93008efe5b9e6aec59247a2167755b03

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