ImplicitDict base class that turns a subclass into a dict indexing attributes, making [de]serialization easy for complex typing-annotated data types.
Project description
implicitdict
This library primarily provides the ImplicitDict
base class which enables the inheriting class to implicitly be treated like a dict
with entries corresponding to the fields of the inheriting class. Simple example:
class MyData(ImplicitDict):
foo: str
bar: int = 0
baz: Optional[float]
data: MyData = ImplicitDict.parse({'foo': 'asdf', 'bar': 1}, MyData)
assert json.dumps(data) == '{"foo": "asdf", "bar": 1}'
See class documentation for ImplicitDict
and test_normal_usage.py for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
implicitdict-1.0.0.tar.gz
(17.1 kB
view hashes)
Built Distribution
Close
Hashes for implicitdict-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3b4df2fc75802fcf23350fec2882a95a4c079a337fa1865cc847ae9a3add427 |
|
MD5 | 83ef3878f3b28fa49c42f645cb5b7440 |
|
BLAKE2b-256 | c3d8a54a0ae8c2eb809276651bc410aefeb13b738f8d73f579350887611dedbb |