Skip to content

Upgrading marshmallow 0.7 to 1

Breaking0.7.0 → 1.2.6Breaking9Deprecated3New15Changed12Fixed28Other11

BreakingUpgrade verdict

9 breaking changes.

  • Custom fields must override the new private methods, and the old format and output attributes no longer exist.
  • Date and time values are now output in ISO8601 format by default, which differs from the previous RFC822 output.
  • The factory method is gone because the new dump method makes it unnecessary.
  • The validated decorator is gone, and validation is handled inside field methods instead.
Top 5 of 12 that need code or config changes
Breaking9
Field classes now implement _serialize and _deserialize; serialize and deserialize are the public API, and Field.format and Field.output are removed.
Field_serialize_deserializeserializedeserializeField.formatField.output
DateTime field now serializes to ISO8601 format by default instead of RFC822.
DateTime
Removes Serializer.factory method, no longer necessary with the dump method.
Serializer.factorydump
Removes the validated decorator; validation now occurs within Field methods.
validatedField
Schema output is no longer an OrderedDict by default; set the ordered option to True for ordered field output.
OrderedDictordered
Renames Serializer to Schema.
SerializerSchema
Removes Serializer.json and Serializer.to_json; use Schema.dumps instead.
Serializer.jsonSerializer.to_jsonSchema.dumps
Allows nesting a serializer within itself recursively; use exclude or only to prevent infinite recursion.
excludeonly
Multiple errors can be stored per field; the errors dict from load and dump maps field names to lists of error messages.
loaddumperrors
Deprecated3
Deprecates the validator functions in the validate module in favor of the class-based validators.
validate
Deprecates the Arbitrary, Price, and Fixed fields in favor of the Decimal field.
ArbitraryPriceFixedDecimal
Deprecates the error parameter of the Field constructor; raise a ValidationError instead.
FielderrorValidationError

Generated by DepDelta from published Python source. Not mixed with prose notes.

  • added: export MarshalResult
  • added: export MarshallingError
  • added: export Schema
  • added: export SchemaOpts
  • added: export UnmarshalResult
  • added: export UnmarshallingError
  • added: export ValidationError
  • removed: class SerializerABC(object)
  • removed: method FieldABC.format(value)
  • removed: method FieldABC.output(key, obj)
  • removed: method SerializerABC.is_valid(fields=…)
  • removed: property SerializerABC.errors
  • added: class SchemaABC(object)
  • added: method FieldABC.deserialize(value)
  • added: method FieldABC.serialize(attr, obj, accessor=…)
  • added: method SchemaABC.dump(obj)
  • added: method SchemaABC.dumps(obj, *args, **kwargs)
  • added: method SchemaABC.load(data)
  • added: method SchemaABC.loads(data)
  • added: function post_dump(fn=…, raw=…)
  • added: function post_load(fn=…, raw=…)
  • added: function pre_dump(fn=…, raw=…)
  • added: function pre_load(fn=…, raw=…)
  • added: function tag_processor(tag_name, fn, raw)
  • added: variable POST_DUMP
  • added: variable POST_LOAD
  • added: variable PRE_DUMP
  • added: variable PRE_LOAD
  • removed: constructor MarshallingError(underlying_exception)
  • changed: class MarshallingError(MarshmallowError) → class MarshallingError(_WrappingException)
  • changed: class RegistryError(NameError, MarshmallowError) → class RegistryError(ForcedError, NameError)
  • added: class ForcedError(_WrappingException)
  • added: class UnmarshallingError(_WrappingException)
  • added: class ValidationError(MarshmallowError)
  • added: constructor ValidationError(message, field=…)
  • removed: constructor Raw(default=…, attribute=…, error=…, validate=…, required=…)
  • removed: function validated(f)
  • removed: method Arbitrary.format(value)
  • removed: method Boolean.format(value)
  • removed: method Date.format(value)
  • removed: method DateTime.format(value)
  • removed: method Email.output(key, obj)
  • removed: method Fixed.format(value)
  • removed: method FormattedString.output(key, obj)
  • removed: method Function.output(key, obj)
  • removed: method List.output(key, data)
  • removed: method Marshaller.marshal(data, fields_dict, many=…)
  • removed: method Method.output(key, obj)
  • removed: method Nested.output(key, obj)
  • removed: method Number.format(value)
  • removed: method Raw.format(value)
  • removed: method Raw.get_value(key, obj)
  • removed: method Raw.output(key, obj)
  • removed: method Select.format(value)
  • removed: method String.format(value)
  • removed: method Time.format(value)
  • removed: method TimeDelta.format(value)
  • removed: method Url.output(key, obj)
  • removed: property Nested.serializer
  • removed: variable ZERO
  • changed: class Boolean(Raw) → class Boolean(Field)
  • changed: class Date(Raw) → class Date(Field)
  • changed: class DateTime(Raw) → class DateTime(Field)
  • changed: class Email(Raw) → class Email(ValidatedField)
  • changed: class FormattedString(Raw) → class FormattedString(Field)
  • changed: class Function(Raw) → class Function(Field)
  • changed: class List(Raw) → class List(Field)
  • changed: class Method(Raw) → class Method(Field)
  • changed: class Nested(Raw) → class Nested(Field)
  • changed: class Number(Raw) → class Number(Field)
  • changed: class Raw(FieldABC) → class Raw(Field)
  • changed: class Select(Raw) → class Select(Field)
  • changed: class String(Raw) → class String(Field)
  • changed: class Time(Raw) → class Time(Field)
  • changed: class TimeDelta(Raw) → class TimeDelta(Field)
  • changed: class Url(Raw) → class Url(ValidatedField)
  • changed: constructor FormattedString(src_str) → constructor FormattedString(src_str, *args, **kwargs)
  • changed: constructor Function(func, **kwargs) → constructor Function(func, deserialize=…, **kwargs)
  • changed: constructor Integer(default=…, attribute=…, as_string=…, error=…, **kwargs) → constructor Integer(default=…, *args, **kwargs)
  • changed: constructor List(cls_or_instance, **kwargs) → constructor List(cls_or_instance, default=…, allow_none=…, **kwargs)
  • changed: constructor Marshaller(prefix=…, strict=…, error_handler=…) → constructor Marshaller(prefix=…)
  • changed: constructor Method(method_name, **kwargs) → constructor Method(method_name, deserialize=…, **kwargs)
  • changed: constructor Nested(nested, exclude=…, only=…, allow_null=…, many=…, **kwargs) → constructor Nested(nested, default=…, exclude=…, only=…, allow_null=…, many=…, **kwargs)
  • changed: constructor Price(decimals=…, **kwargs) → constructor Price(decimals=…, default=…, **kwargs)
  • added: class Decimal(Number)
  • added: class Field(FieldABC)
  • added: class QuerySelect(Field)
  • added: class QuerySelectList(QuerySelect)
  • added: class Unmarshaller(object)
  • added: constructor Decimal(places=…, rounding=…, default=…, as_string=…, **kwargs)
  • added: constructor Email(*args, **kwargs)
  • added: constructor Field(default=…, attribute=…, error=…, validate=…, required=…, **metadata)
  • added: constructor QuerySelect(query, keygetter, error=…, **kwargs)
  • added: constructor Unmarshaller()
  • added: field Boolean.falsy
  • added: field Boolean.truthy
  • added: field DateTime.DEFAULT_FORMAT
  • added: field Decimal.num_type
  • added: field Field.SKIPPABLE_VALUES
  • added: field FormattedString.SKIPPABLE_VALUES
  • added: field List.SKIPPABLE_VALUES
  • added: field String.SKIPPABLE_VALUES
  • added: method Field.deserialize(value)
  • added: method Field.get_value(attr, obj, accessor=…)
  • added: method Field.serialize(attr, obj, accessor=…)
  • added: method Marshaller.serialize(obj, fields_dict, many=…, strict=…, skip_missing=…, accessor=…, dict_class=…)
  • added: method Number.serialize(attr, obj, accessor=…)
  • added: method QuerySelect.keys()
  • added: method QuerySelect.labels(labelgetter=…)
  • added: method QuerySelect.pairs()
  • added: method QuerySelect.results()
  • added: method Unmarshaller.deserialize(data, fields_dict, many=…, validators=…, preprocess=…, postprocess=…, strict=…, dict_class=…)
  • added: property Field.context
  • added: property Nested.schema
  • added: variable Bool
  • added: variable Int
  • added: variable Str
  • added: variable URL
  • added: variable missing
  • added: variable null
  • added: class Marshaller(ErrorStore)
  • added: class Unmarshaller(ErrorStore)
  • added: constructor Marshaller(prefix=…)
  • added: method Marshaller.serialize(obj, fields_dict, many=…, strict=…, skip_missing=…, accessor=…, dict_class=…, index_errors=…, index=…)
  • added: method Unmarshaller.deserialize(data, fields_dict, many=…, validators=…, preprocess=…, postprocess=…, strict=…, dict_class=…, index_errors=…, index=…)
  • added: class OrderedSet(collections.MutableSet)
  • added: constructor OrderedSet(iterable=…)
  • added: method OrderedSet.add(key)
  • added: method OrderedSet.discard(key)
  • added: method OrderedSet.pop(last=…)
  • added: variable s
  • added: variable t
  • added: class BaseSchema(base.SchemaABC)
  • added: class BaseSchema.Meta(object)
  • added: class Schema(with_metaclass(SchemaMeta, BaseSchema))
  • added: class SchemaMeta(type)
  • added: class SchemaOpts(object)
  • added: constructor BaseSchema(obj=…, extra=…, only=…, exclude=…, prefix=…, strict=…, many=…, skip_missing=…, context=…)
  • added: constructor SchemaOpts(meta)
  • added: field BaseSchema.OPTIONS_CLASS
  • added: field BaseSchema.TYPE_MAPPING
  • added: field SchemaMeta.FUNC_LISTS
  • added: method BaseSchema.dump(obj, many=…, update_fields=…, **kwargs)
  • added: method BaseSchema.dumps(obj, many=…, update_fields=…, *args, **kwargs)
  • added: method BaseSchema.load(data, many=…)
  • added: method BaseSchema.loads(json_data, many=…, *args, **kwargs)
  • added: method BaseSchema.make_object(data)
  • added: method BaseSchema.validate(data, many=…)
  • added: property BaseSchema.data
  • added: property BaseSchema.dict_class
  • added: property BaseSchema.errors
  • added: property BaseSchema.set_class
  • added: static method BaseSchema.accessor(func)
  • added: static method BaseSchema.data_handler(func)
  • added: static method BaseSchema.error_handler(func)
  • added: static method BaseSchema.preprocessor(func)
  • added: static method BaseSchema.validator(func)
  • added: variable MarshalResult
  • added: variable Serializer
  • added: variable UnmarshalResult
  • changed: class BaseSerializer(base.SerializerABC) → class BaseSerializer(base.SchemaABC)
  • changed: function from_rfc(datestring) → function from_rfc(datestring, use_dateutil=…)
  • added: function callable_or_raise(obj)
  • added: function decimal_to_fixed(value, precision)
  • added: function ensure_text_type(val)
  • added: function from_datestring(datestring)
  • added: function from_iso(datestring, use_dateutil=…)
  • added: function from_iso_date(datestring, use_dateutil=…)
  • added: function from_iso_time(timestring, use_dateutil=…)
  • added: function get_callable_name(func)
  • added: function get_func_args(func)
  • added: function get_func_name(func)
  • added: function get_value(key, obj, default=…)
  • added: function is_generator(obj)
  • added: function is_keyed_tuple(obj)
  • added: function pluck(dictlist, key)
  • added: variable ZERO_DECIMAL
  • added: variable dateutil_available
  • removed: variable DOMAIN_REGEX
  • removed: variable DOMAIN_WHITELIST
  • removed: variable RELATIVE_URL_REGEX
  • removed: variable URL_REGEX
  • removed: variable USER_REGEX
  • changed: function email(value) → function email(value, error=…)
  • changed: function url(value, relative=…) → function url(value, relative=…, error=…)
  • added: class Email(object)
  • added: class Equal(object)
  • added: class Length(Range)
  • added: class NoneOf(object)
  • added: class Predicate(object)
  • added: class Range(object)
  • added: class Regexp(object)
  • added: class URL(object)
  • added: constructor Email(error=…)
  • added: constructor Equal(comparable, error=…)
  • added: constructor NoneOf(iterable, error=…)
  • added: constructor Predicate(method, error=…, **kwargs)
  • added: constructor Range(min=…, max=…, error=…)
  • added: constructor Regexp(regex, flags=…, error=…)
  • added: constructor URL(relative=…, error=…)
  • added: field Email.DOMAIN_REGEX
  • added: field Email.DOMAIN_WHITELIST
  • added: field Email.USER_REGEX
  • added: field Length.message_all
  • added: field Length.message_max
  • added: field Length.message_min
  • added: field Range.message_all
  • added: field Range.message_max
  • added: field Range.message_min
  • added: field URL.RELATIVE_URL_REGEX
  • added: field URL.URL_REGEX
  • added: function equal(value, comparable, error=…)
  • added: function length(value, min=…, max=…, error=…)
  • added: function predicate(value, method, error=…, **kwargs)
  • added: function ranging(value, min=…, max=…, error=…)
  • added: function regexp(value, regex, flags=…, error=…)