Skip to main content

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


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.1.0.tar.gz (17.3 kB view hashes)

Uploaded Source

Built Distribution

implicitdict-1.1.0-py3-none-any.whl (13.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page