Skip to main content

A utility library to map between dataclass

Project description

Python 3.7 helper tool to work with mapping of dataclasses.

It allow automapping a dataclass attributes

from automapping import Mapper, Rename

class InnerA:
    number: int
    list_of_values: List[str]
    untyped_list: list

class A:
    name: str
    id_a: int
    inner: InnerA

class InnerB:
    number: int
    list_of_values: List[str]
    untyped_list: list

class B:
    name: str
    id_b: int
    inner: InnerB

mapper = Mapper()
mapper.add_mapper(AutoMap(A, B, [
    Rename('id_a', 'id_b')
mapper.add_mapper(AutoMap(InnerA, InnerB))

input_a = A(name='Paul', id_a=6, inner=InnerA(
    number=10, list_of_values=['a', 'b'], untyped_list=[1, True]))
result =, B, ObjectDictTypeUpdater)
print(result) # B(name='Paul', id_b=6, inner=InnerB(number=10, list_of_values=['a', 'b'], untyped_list=[1, True]))

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

automapping-0.0.1.tar.gz (7.8 kB view hashes)

Uploaded source

Supported by

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