Registry / serialization / marshmallow3-annotations

marshmallow3-annotations

JSON →
library1.1.0pypypiunverified

A library that allows using Python type annotations to define marshmallow 3 schemas, automatically generating Schema classes from annotated dataclasses or models. Version 1.1.0 supports dicts; release cadence is sporadic.

pip install marshmallow3-annotations
INSTALL
IMPORT
SIG · MARSHMALLOW3-ANNOT
M
marshmallow3-annotations
serializationpythonv1.1.0
Install
1.7s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

annotation_schema
from marshmallow3_annotations import annotation_schema
from marshmallow3_annotations import annotation_schema

Decorate a dataclass with type annotations, then call annotation_schema to generate a marshmallow Schema.

from marshmallow import Schema, fields from marshmallow3_annotations import annotation_schema from dataclasses import dataclass @dataclass class User: name: str email: str UserSchema = annotation_schema(User) # Use UserSchema like any marshmallow Schema schema = UserSchema() result = schema.dump(User(name='John', email='john@example.com')) print(result) # {'name': 'John', 'email': 'john@example.com'}
Debug
Known issues
gotchaannotation_schema expects a class, not an instance. Pass the class itself.
fix
UserSchema = annotation_schema(User)  # not User()
affects: all
gotchaOnly simple types like str, int, float, bool, list, dict are supported. Custom types or nested dataclasses may not work.
fix
Use marshmallow fields directly for complex types, or define a nested schema manually.
affects: <=1.1.0
deprecatedThe library may not be actively maintained; consider using marshmallow-dataclass or marshmallow-dataclass3 instead.
fix
Migrate to marshmallow-dataclass (more features) or marshmallow-dataclass3 (Python 3.7+).
affects: all
Upgrade
Version history
1.1.0latest on PyPI · released May 31, 2022
Audit
Dependencies
marshmallowrequiredCore dependency; generates marshmallow schemas
dataclassesoptionalUsed for defining annotated models
Agent activity
14 hits · last 30 days
node
14
Resources
marshmallow3-annotations — pip install marshmallow3-annotations · libregistry