Skip to main content

Union fields for marshmallow.

Project description

Union fields for marshmallow.

  • Free software: MIT license

Warning

This library works by trying a list of fields one by one, and (de)serializing with the first one not to raise an error. The type of the values is not taken into account, so if one of the fields in the union accepts values of an unexpected type, they will be used for serialization. This can lead to a surprising behavior, because :

u = Union(fields=[fields.Integer(), fields.String()]) # the Integer field accepts string representations of integers
type(u.deserialize('0')) # -> int

If you want to have precise control of which field will be used for which value, you can use marshmallow-polyfield instead of this library.

Documentation

https://python-marshmallow-union.readthedocs.io/

0.1.15 (2020-05-30)

Changes

  • Fix #32 : Never ignore the value passed to _serialize. Notably, this fixes the serialization of lists of unions, such as List(Union([Int(), String()]))

0.1.12 (2019-10-24)

Backward-incompatible Changes

  • On serialization, marshmallow_union.ExceptionGroup is raised if all candidate fields fail. #24

0.1.11 (2019-06-19)

Changes

  • Override the underscore-prefixed methods instead of the plain ones #22

Changelog

0.1.10 (2019-06-08)

Changes

  • Use Towncrier for changelog. #18

0.1.0 (2019-06-07)

  • First release on PyPI.

Project details


Download files

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

Files for marshmallow-union, version 0.1.15.post1
Filename, size File type Python version Upload date Hashes
Filename, size marshmallow_union-0.1.15.post1-py2.py3-none-any.whl (4.6 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size marshmallow-union-0.1.15.post1.tar.gz (17.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page