Dataclass-mapper

Latest version: v1.9.3

Safety actively analyzes 702088 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 5

2.0.0a4

Features:
- If you pass a custom callable to the mapping, and the callable is annotated with types, the types will be checked and a typeerror is raised if the types are not compatible with the source class / target field. Fixes 32
python
dataclass
class Source:
x: int

dataclass
class Target:
x: str

def x_to_str(source: Source) -> str:
return str(source.x)

create_mapper(Source, Target, {"x": x_to_str})

- It's now also possible to map a subtype field to a super type field.
python
class FooBase: pass
class Foo(FooBase): pass

dataclass
class Source:
foo: Foo

dataclass
class Target:
foo: FooBase

create_mapper(Foo, FooBase)

2.0.0a3

Changes:

- Support SQLAlchemy's MappedAsDataclass feature
Fixes 29

2.0.0a2

Changes:

- Support for UUID type in SQLAlchemy models (even if the database doesn't native support for UUIDs)
Fixes 31
- Better handling of unsupported data types (ignore errors if field is not used, or when you can just copy the field)
Fixes 30

2.0.0a1

Changes:
- Simple Types: extract a single value from a dataclass / create a dataclass from a single value

2.0.0a0

Alpha release.
The release is not backwards compatible with version v1.9.x.

Documentation: https://dataclass-mapper.readthedocs.io/en/latest/

A detailed upgrade guide and list of all new features will follow for the release.
Overview over all changes:

- Major rewrite (generate AST instead of code as string, major refactorings)
- Feature: Updating models
- Feature: Support for SQLAlchemy models
- Feature: Init parameter for dataclasses
- Breaking change: handling of optional source fields
- Breaking change: extra context
- Improvement: additional types and mappings for complicated fields

1.9.3

Technical improvement: documentation build

The https://readthedocs.org build changed a bit, so the old documentation didn't build anymore because of the theme.

Page 1 of 5

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.