adaptix
adaptix copied to clipboard
Add several fields linking
example:
@dataclass
class User:
first_name: str
last_name: str
@dataclass
class UserResponse:
full_name: str
converter_user_to_response = get_converter(
User,
UserResponse,
recipe=[
link(
P[User].first_name & P[User].last_name,
P[UserResponse].full_name,
coercer=lambda first_name, last_name: f"{first_name} {last_name}"
)
]
)