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.3.0.tar.gz
(27.2 kB
view hashes)
Built Distribution
Close
Hashes for implicitdict-2.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8861d017bef318353f6eb71d2bed782d938ee74cb202f5fcdf64176f937c7be8 |
|
MD5 | ecafb4c9f7d7a28763bbbd825b5f7669 |
|
BLAKE2b-256 | 3c930d57f0e1a65f4bbe2c846b50dda0c6e367ddcefe6cfac14fd1a594bf9e66 |