diff --git a/docs/index.md b/docs/index.md index eb5c5d1..bae059b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,19 +10,18 @@ --- -Extension for `marshmallow` to make deserialization to objects easier and improve type safety. +Extension for **`marshmallow`** to make deserialization to objects easier and improve type safety. The main `GenericSchema` class extends `marshmallow.Schema` making it **generic** in terms of the class that data should be deserialized to, when calling `load`/`loads`. With `GenericSchema` there is no need to explicitly write `post_load` hooks to initialize the object anymore. 🎉 -If the "model" class is (for example) `User`, it just needs to be passed as the type argument, when subclassing `GenericSchema`. Depending on whether `many` is `True` or not, the output of the `load`/`loads` method will then be automatically inferred as either `User` or `list[User]` by any competent type checker. ✨ +If the "model" class is (for example) `User`, it just needs to be passed as the type argument, when subclassing `GenericSchema`. The output of the `load`/`loads` method will then be automatically inferred as either `User` or `list[User]` (depending on whether `many` is `True` or not) by any competent type checker. ✨ ## Usage Example ```python -from marshmallow import fields -from marshmallow_generic import GenericSchema +from marshmallow_generic import GenericSchema, fields class User: diff --git a/src/marshmallow_generic/__init__.py b/src/marshmallow_generic/__init__.py index 42775d2..f6fa1a4 100644 --- a/src/marshmallow_generic/__init__.py +++ b/src/marshmallow_generic/__init__.py @@ -19,5 +19,41 @@ __doc__ = """ Generic schema with full typing support and minimal boilerplate. """ -from .decorators import post_load -from .schema import GenericSchema +__all__ = [ + # Custom: + "GenericSchema", + "post_load", + # Re-exports from marshmallow: + "EXCLUDE", + "INCLUDE", + "RAISE", + "Schema", + "SchemaOpts", + "fields", + "validates", + "validates_schema", + "pre_dump", + "post_dump", + "pre_load", + # "post_load", + "pprint", + "ValidationError", + "missing", +] + +from marshmallow import fields + +from marshmallow.decorators import ( + post_dump, + # post_load, # overloaded + pre_dump, + pre_load, + validates, + validates_schema, +) +from marshmallow.exceptions import ValidationError +from marshmallow.schema import Schema, SchemaOpts +from marshmallow.utils import EXCLUDE, INCLUDE, RAISE, missing, pprint + +from marshmallow_generic.decorators import post_load +from marshmallow_generic.schema import GenericSchema