Adaptix
raw JSON → 3.0.0b12 verified Sat May 09 auth: no python
An extremely flexible and configurable data model conversion library for Python 3.10+, currently at v3.0.0b12. It allows loading, dumping, and conversion between different model types (dataclasses, pydantic, msgspec, SQLAlchemy, etc.) with a powerful recipe-based provider system. The library is in active beta development with frequent releases.
pip install adaptix Common errors
error adaptix.ProviderNotFoundError: Cannot produce loader for type ... ↓
cause The Recipe does not have a provider for the requested conversion, or the type cannot be automatically converted (e.g., unsupported type or missing integration).
fix
Ensure the type is registered (e.g., for Pydantic models, add the pydantic provider) or add a custom coercer via link.
error ModuleNotFoundError: No module named 'adaptix' ↓
cause adaptix is not installed.
fix
Run 'pip install adaptix'.
error AttributeError: module 'adaptix' has no attribute 'loader' ↓
cause Imported from wrong location; loader is in adaptix.conversion.
fix
Use 'from adaptix.conversion import loader'.
Warnings
deprecated The 'NoSuitableProvider' exception was renamed to 'ProviderNotFoundError' in v3.0.0b7. The old name is still available as an alias but will be removed in a future version. ↓
fix Replace 'NoSuitableProvider' with 'ProviderNotFoundError' in your exception handlers.
gotcha Recipe is immutable and expensive to create. Do not create a new Recipe for every conversion call; reuse the same Recipe instance for the same set of types. ↓
fix Create a single Recipe at application startup and reuse it.
breaking In v3.0.0b9, all iterables are now dumped to tuple (or list for list children). Previously, some iterables were dumped as generators or other types. ↓
fix If you rely on the dumped type being a specific iterable (e.g., set), you must add a custom coercer or post-process the output.
gotcha When working with Optional types, a coercer defined for the inner type may not be applied if the destination type is exactly Optional[InnerType]. Use the special handling for Optional. ↓
fix Upgrade to >=3.0.0b7 where Optional coercer redefinition is allowed.
Imports
- Recipe wrong
from adaptix.recipe import Recipecorrectfrom adaptix import Recipe - loader, dumper, converter wrong
from adaptix import loadercorrectfrom adaptix.conversion import loader, dumper, converter - ProviderNotFoundError wrong
from adaptix.errors import ProviderNotFoundErrorcorrectfrom adaptix import ProviderNotFoundError
Quickstart
from dataclasses import dataclass
from adaptix import Recipe
from adaptix.conversion import loader, dumper
@dataclass
class User:
id: int
name: str
recipe = Recipe()
# Load User from dict
data = {'id': 1, 'name': 'Alice'}
load = recipe.ask(loader, User)
user = load(data)
print(user)
# Dump User to dict
dump = recipe.ask(dumper, User)
dumped = dump(user)
print(dumped)