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

Uploaded Source

Built Distribution

pavlova-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file pavlova-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for pavlova-0.1.0.tar.gz
Algorithm Hash digest
SHA256 18d1e49f43d6c97820b33d8d09078f4982ec27deb370372fd4c9385bd7b2c6a8
MD5 36998cd398a4076e3d66f40d5717e556
BLAKE2b-256 5a949bc3d173739a85de6a74e00ff358dc33d6f97d54cf6c1b1dbc9ee3ea65ae

See more details on using hashes here.

File details

Details for the file pavlova-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pavlova-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for pavlova-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 deaffba8dcc941dff4686d613fe71bf7d62209c378e4cd030e44de71e3cb856a
MD5 9d447d2322e19e8608c1a985e1316cda
BLAKE2b-256 810cd87767cdbe076c7bfa48875ac25a874ab0c6325a4e932763f04d1224dbee

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