Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

YAAB aims to provide a flexible base for Adapter Design Pattern implementations based on dataclasses.

Project description

Yet Another Adapter Base Documentation Status

YAAB aims to provide a flexible base for Adapter Design Pattern implementations based on dataclasses.

Example Usage

Let’s assume that you are interfacing an API that returns a JSON object with the following structure:

    "weird_name": "My name",
    "oid": "3"

And you would like to transform it into a schema that fits the rest of your API, let’s assume:

    "name": "My name",
    "id": 3

Then you would define and use your model in the following way:

>>> from dataclasses import asdict, dataclass, field
>>> from yaab.adapter import BaseAdapter
>>> @dataclass
... class MyModel(BaseAdapter):
...     id: int = field(metadata={"transformations": ("oid", int)})
...     name: str = field(metadata={"transformations": ("weird_name", )})
>>> m = MyModel.from_dict({"weird_name": "My name", "oid": "3"})
>>> print(m)
MyModel(id=3, name='My name')
>>> asdict(m)
{'id': 3, 'name': 'My name'}


  • TODO


This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.


0.2.2 (2020-05-03)

  • Introduce type conversion & convenience Mixins

0.2.1 (2020-02-18)

  • Bugfix: from_env now utilizes default values.

0.2.0 (2020-02-18)

  • Add dataclass nesting support.

0.1.0 (2020-01-21)

  • First release on PyPI.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for yaab, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size yaab-0.2.2-py2.py3-none-any.whl (5.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size yaab-0.2.2.tar.gz (10.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page