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.0.tar.gz
(25.9 kB
view hashes)
Built Distribution
Close
Hashes for implicitdict-2.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc53e214ea04d649957295f19e68fe13702513ce7d59bdcc12f7d3085c0165cd |
|
MD5 | 3d4a19b37ef9d1547104bb80b648ba5b |
|
BLAKE2b-256 | 266a0ed345f50446dace8c65b48b26320d26482bfe3d3709e03510d5f95dc402 |