Skip to main content

Some extra sweets for marshmallow.

Project description

Some extra sweets for marshmallow.

version pipeline status coverage report

Examples

Use annotations for schema description.

class Response(Schema):
    a: float
    b: Optional[dt.datetime]

When annotations not enough

class Response(Schema):
    c: str = fields.Email()

And IDE autocomplete cause now your data is instances of relevant classes

class User(Schema):
    name: str

class Response(Schema):
    user: User

response: Response = Response.load({"user": {"name": "Vasya Pupkin"}})
response.user.name

Mapping rules

Basic Types

annotation

marshmallow field

str

fields.String

float

fields.Float

bool

fields.Boolean

int

fields.Integer

uuid.UUID

fields.UUID

decimal.Decimal

fields.Decimal

dt.datetime

fields.DateTime

dt.time

fields.Time

dt.date

fields.Date

dt.timedelta

fields.TimeDelta

All fields will be required for make it optional use typing.Optional[X]

Many

annotation

marshmallow field

list

fields.Raw(many=True)

typing.List[float]

fields.List(fields.Float())

Nested

annotation

marshmallow field

NestedSchema

fields.Nested(NestedSchema, required=True)

typing.Optional[NestedSchema]

fields.Nested(NestedSchema, required=True)

typing.List[NestedSchema]

fields.Nested(NestedSchema, required=True, many=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marshmallow-jam-0.1.1.dev48249440.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file marshmallow-jam-0.1.1.dev48249440.tar.gz.

File metadata

  • Download URL: marshmallow-jam-0.1.1.dev48249440.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for marshmallow-jam-0.1.1.dev48249440.tar.gz
Algorithm Hash digest
SHA256 389c205815a2e7912c0915ba9f4e660eaf36e06d6192263d37cad5197992ce67
MD5 cce4828ffa3a17b8f2d80baa6c3f3171
BLAKE2b-256 07dc7bcf619b507f104899dfdff5239bf810f8abbfff7ff78b8f03d361e364e1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page