Serializer
A serialization module for python objects
Quickstart
pip install py-serializer
from typing import List
from serializer import serializable
@serializable
class Role:
role_type: str
attributes: List[str]
@serializable
class Person:
name: str
age: int
height: float
weight: float
address: str
role: List[Role]
p = Person(
name="Paul", age=25, height=1.70, weight=83.5, address="earth",
role=[Role(role_type='human', attributes=['speak', 'eat', 'sleep'])]
)
print(p.to_dict())
{ 'name': 'Paul', 'age': 25, 'height': 1.7, 'weight': 83.5, 'address': 'earth', 'role': [ { 'role_type': 'human', 'attributes': ['speak', 'eat', 'sleep'] } ] }
Serializable wrapper extends dataclass so you can treat it like a normal dataclass.
Mixin
It is possible to have a class extend abstract class SerializableMixin
from serializer import SerializableMixin, serializer
class Test(SerializableMixin):
def __init__(self, name: str):
self.name = name
def __serialize__(self):
return dict(name=serializer(self.name))
>> Test(name='Paul').to_dict()
{ 'name': 'Paul' }
For object to be seriazable they only need to implement a __serialize__ method.
Metadata
Release files for py-serializer 0.9.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py-serializer-0.9.6.tar.gz | 4.8 kB | Without provenance | Details for py-serializer-0.9.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_serializer-0.9.6-py3-none-any.whl | Python 3 | none | any | Details for py_serializer-0.9.6-py3-none-any.whl |
Total release size: 11.5 kB
Release files / py-serializer-0.9.6.tar.gz
| Download URL | py-serializer-0.9.6.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9315d10697a6901226e1dda13289e0b57fc9fab3a260162a1ef4ac214afddd19
|
|
BLAKE2b-256 checksum How to use checksums |
6ddc3fe8679b1d015c0afd3304bcd51685de4854482a33a2e80fd8ecc89d791c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1
|
Release files / py_serializer-0.9.6-py3-none-any.whl
| Download URL | py_serializer-0.9.6-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e751f43f882cfcffe50ae0209fe684c2a059c6e9e1771825342cb49796d04f38
|
|
BLAKE2b-256 checksum How to use checksums |
6a7f0e2f677a90eeec36d538d6eaee5f766b83905a624a78c7f1e119213a6ad1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1
|
Security for py-serializer 0.9.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.