serializepy: typed deserialization
File issues here: Issues tracker
Motivation
serializepy inspects the type-hints of self-assignments in class-constructors, and constructs the type from a given dictionary. The goal is to support this work recursively for large and complex (typed) hierarchies.
Installation
Install serializepy with pip:
$ python3 -m pip install serializepy
Usage
# Example class hierarchy
class B():
def __init__(self, b: int) -> None:
self.b: int = b
class A():
def __init__(self, a: int, b: B) -> None:
self.a: int = a
self.b: B = b
# Data that we want to fit the above hierarchy, possibly from json.load(..)
d = {
'a': 1,
'b': {
'b': 2
}
}
# Deserialization and assertion
obj: A = deserialize(A, d)
assert isinstance(obj, A)
assert obj.a == 1
assert isinstance(obj.b, B)
assert obj.b.b == 2
Inheritance:
class A():
def __init__(self, a: int) -> None:
self.a: int = a
class B(A):
def __init__(self, a: int, b: int) -> None:
super().__init__(a)
self.b: int = b
d = {
'a': 5,
'b': 7
}
obj: B = deserialize(B, d)
assert isinstance(obj, B)
assert obj.a == 5
assert obj.b == 7
License
serializepy is licensed under the terms of the MIT License (see the LICENSE file).
Metadata
Release files for serializepy 0.0.2
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 |
|---|---|---|---|---|
| serializepy-0.0.2.tar.gz | 6.1 kB | Without provenance | Details for serializepy-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| serializepy-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for serializepy-0.0.2-py3-none-any.whl |
Total release size: 15.6 kB
Release files / serializepy-0.0.2.tar.gz
| Download URL | serializepy-0.0.2.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ed3566a10ee7a2bfb08e25630f62be27175d99acdf2123d7893fdff664ae48a
|
|
BLAKE2b-256 checksum How to use checksums |
770ac27de5cbd5600a484a0e2091d00d23ca225e7ec313e9f4e7e9d871f8f169
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.6.13
|
Release files / serializepy-0.0.2-py3-none-any.whl
| Download URL | serializepy-0.0.2-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ac69dfb329ab63128f4b290aebeaaa3b9ffe225162c86aa7512f1f981216bd9
|
|
BLAKE2b-256 checksum How to use checksums |
f8535beb5ce130aa81b6e1e78739a42c816d0df3726cd177ed4e24b4666dcc0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.6.13
|
Security for serializepy 0.0.2
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.