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-2.1.1.tar.gz
(22.2 kB
view hashes)
Built Distribution
Close
Hashes for implicitdict-2.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a76a5ecd4910d85a5a1f5ce1df1de24a1a406b7eb04e2a708714ea7d58b23879 |
|
MD5 | 866ab5fce35ea1433bf0ccdf836316d1 |
|
BLAKE2b-256 | c4cd5700f3303198a39216e753fcaf7e58e61ccd92eb7e7ee41a305d0860dea2 |