9.1. ADR 001: Write a new library
9.1.1. Status
Accepted. December 10, 2022
9.1.2. Context
For a closed-source project I needed a library that helped mapping between two dataclasses. I already had some helper functions, that did parts of this library, but it felt unsafe, and mixed responsibilities (business logic and mappings) too much.
The basic requirements are more or less the requirements from Requirements Overview.
There are a couple of libraries out there, that perform some such tasks.
odin: A new dataclass implementation, where you can define mappings. But no support for
dataclassesorpydantic.object-mapper: Similar mapping definitions, but no type validation. Also it’s unmaintained, and only supports Python <=3.8.
panamap: Similar, but no type validation. Looks unmaintained.
automapping: Similar, but more a proof-of-concept library than a maintained implementation.
py-automapper: Supports
dataclasses,pydanticand many more dataclass implementations. But no typing checks, and doesn’t work for recursive objects.pydantic’s ORM Mode: too restricted when mapping between field with different names
Alternatively I can write a new library.
9.1.3. Decision
Writing and maintaining a new library is hard work. But since none of the other solutions satisfies the majority of the requirements, or is unmaintained, that’s the only acceptable option.
9.1.4. Consequences
Start writing a new library.