{"id":21554,"library":"marshmallow3-annotations","title":"marshmallow3-annotations","description":"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.","status":"active","version":"1.1.0","language":"python","source_language":"en","source_url":"https://github.com/dkunitsk/marshmallow3-annotations","tags":["marshmallow","annotations","schema","dataclass"],"install":[{"cmd":"pip install marshmallow3-annotations","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Core dependency; generates marshmallow schemas","package":"marshmallow","optional":false},{"reason":"Used for defining annotated models","package":"dataclasses","optional":true}],"imports":[{"note":"Correct import uses underscore, no alias needed","wrong":"from marshmallow3_annotations import annotation_schema as old_name","symbol":"annotation_schema","correct":"from marshmallow3_annotations import annotation_schema"},{"note":"","wrong":"","symbol":"AnnotationSchema","correct":"from marshmallow3_annotations import AnnotationSchema"}],"quickstart":{"code":"from marshmallow import Schema, fields\nfrom marshmallow3_annotations import annotation_schema\nfrom dataclasses import dataclass\n\n@dataclass\nclass User:\n    name: str\n    email: str\n\nUserSchema = annotation_schema(User)\n# Use UserSchema like any marshmallow Schema\nschema = UserSchema()\nresult = schema.dump(User(name='John', email='john@example.com'))\nprint(result)  # {'name': 'John', 'email': 'john@example.com'}","lang":"python","description":"Decorate a dataclass with type annotations, then call annotation_schema to generate a marshmallow Schema."},"warnings":[{"fix":"UserSchema = annotation_schema(User)  # not User()","message":"annotation_schema expects a class, not an instance. Pass the class itself.","severity":"gotcha","affected_versions":"all"},{"fix":"Use marshmallow fields directly for complex types, or define a nested schema manually.","message":"Only simple types like str, int, float, bool, list, dict are supported. Custom types or nested dataclasses may not work.","severity":"gotcha","affected_versions":"<=1.1.0"},{"fix":"Migrate to marshmallow-dataclass (more features) or marshmallow-dataclass3 (Python 3.7+).","message":"The library may not be actively maintained; consider using marshmallow-dataclass or marshmallow-dataclass3 instead.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install with: pip install marshmallow3-annotations. Then import: from marshmallow3_annotations import annotation_schema","cause":"Incorrect import path (maybe using hyphens or different casing).","error":"ModuleNotFoundError: No module named 'marshmallow3_annotations'"},{"fix":"Call annotation_schema with the class itself: annotation_schema(MyClass)","cause":"Passing an instance instead of the class, or no argument.","error":"TypeError: annotation_schema() missing 1 required positional argument: 'cls'"},{"fix":"Ensure the class is a dataclass with type-annotated fields (e.g., name: str).","cause":"annotation_schema returned None or the generated schema is empty because the dataclass has no annotated fields.","error":"AttributeError: 'NoneType' object has no attribute 'fields'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}