Skip to main content

Python dataclass serializer/deserializer

Project description

Mew: python dataclass serializer/deserializer

Build Status Python Version Support PyPI Version Coverage Code style: black image

from dataclasses import dataclass
from enum import Enum
from typing import List

import mew


class Type(Enum):
    normal = 'normal'
    electric = 'electric'
    fire = 'fire'
    fighting = 'fighting'
    water = 'water'
    psychic = 'psychic'


@mew.serializable
@dataclass
class Pokemon:
    name: str
    pokedex: int
    type: Type
    abilities: List[str]


>>> pikachu = Pokemon('Pikachu', 25, Type.electric, ['static', 'lightning rod'])

>>> pikachu
Pokemon(name='Pikachu', pokedex=25, type=<Type.electric: 'electric'>, abilities=['static', 'lightning rod'])

>>> pikachu.dumps()
'{"name": "Pikachu", "pokedex": 25, "type": "electric", "abilities": ["static", "lightning rod"]}'

>>> assert pikachu == Pokemon.loads(pikachu.dumps())

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

mew-0.1.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

mew-0.1.4-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file mew-0.1.4.tar.gz.

File metadata

  • Download URL: mew-0.1.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for mew-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8d38595e049aed4f580dea9b0537a94be275adc3c1e67bfa51689a9465a04de0
MD5 8ed2e5c2a1dbe661f48342f7c29e3781
BLAKE2b-256 ab65ba5ccbcc6079982eee4bd353c840e961dddc5d57bde902a674f561c39edb

See more details on using hashes here.

File details

Details for the file mew-0.1.4-py2.py3-none-any.whl.

File metadata

  • Download URL: mew-0.1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for mew-0.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f4a7d2652bcb4eec10a105930200574c201733ec25c88cb0fb8e8c03eec61e97
MD5 d84fc3b6571887db9dc73cd95ae9817f
BLAKE2b-256 1254217c0df8bce456f93b019d7dac9310b498615f68de804205e8dbcd9f02f8

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