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.2.1.tar.gz
(25.9 kB
view hashes)
Built Distribution
Close
Hashes for implicitdict-2.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 141180323597d7e6d49f5db947d3ae5cd286a0fa44667ff34932a70b665e7a5e |
|
MD5 | c8900feb6100ec4bf6567592e53d5179 |
|
BLAKE2b-256 | a2f597f2d0334e1aa8a64eee08d048c53dd17611b2f8c971b01d0879cd352229 |