Hello community, here is the log from the commit of package python-marshmallow for openSUSE:Factory checked in at 2019-09-13 14:58:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-marshmallow (Old) and /work/SRC/openSUSE:Factory/.python-marshmallow.new.7948 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-marshmallow" Fri Sep 13 14:58:49 2019 rev:10 rq:730134 version:3.0.3 Changes: -------- --- /work/SRC/openSUSE:Factory/python-marshmallow/python-marshmallow.changes 2019-08-27 10:27:32.451913742 +0200 +++ /work/SRC/openSUSE:Factory/.python-marshmallow.new.7948/python-marshmallow.changes 2019-09-13 14:58:51.373278603 +0200 @@ -1,0 +2,8 @@ +Wed Sep 11 12:45:35 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 3.0.3: + * Handle when data_key is an empty string + * Includes bug fix from 2.20.3 + * Fix incorrect super() call in SchemaMeta.__init__ + +------------------------------------------------------------------- Old: ---- marshmallow-3.0.1.tar.gz New: ---- marshmallow-3.0.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-marshmallow.spec ++++++ --- /var/tmp/diff_new_pack.Pq5jJ2/_old 2019-09-13 14:58:51.833278623 +0200 +++ /var/tmp/diff_new_pack.Pq5jJ2/_new 2019-09-13 14:58:51.833278623 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-marshmallow -Version: 3.0.1 +Version: 3.0.3 Release: 0 Summary: ORM/ODM/framework-agnostic library to convert datatypes from/to Python types License: MIT AND BSD-3-Clause ++++++ marshmallow-3.0.1.tar.gz -> marshmallow-3.0.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/AUTHORS.rst new/marshmallow-3.0.3/AUTHORS.rst --- old/marshmallow-3.0.1/AUTHORS.rst 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/AUTHORS.rst 2019-09-05 03:44:00.000000000 +0200 @@ -136,3 +136,5 @@ - Stanislav Rogovskiy `@atmo <https://github.com/atmo>`_ - Cristi Scoarta `@cristi23 <https://github.com/cristi23>`_ - Anthony Sottile `@asottile <https://github.com/asottile>`_ +- Charles-Axel Dein `@charlax <https://github.com/charlax>`_ +- `@phrfpeixoto <https://github.com/phrfpeixoto>`_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/CHANGELOG.rst new/marshmallow-3.0.3/CHANGELOG.rst --- old/marshmallow-3.0.1/CHANGELOG.rst 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/CHANGELOG.rst 2019-09-05 03:44:00.000000000 +0200 @@ -1,6 +1,22 @@ Changelog --------- +3.0.3 (2019-09-04) +++++++++++++++++++ + +Bug fixes: + +- Handle when ``data_key`` is an empty string (:issue:`1378`). + Thanks :user:`jtrakk` for reporting. + +3.0.2 (2019-09-04) +++++++++++++++++++ + +Bug fixes: + +- Includes bug fix from 2.20.3 (:pr:`1376`). +- Fix incorrect ``super()`` call in ``SchemaMeta.__init__`` (:pr:`1362`). + 3.0.1 (2019-08-21) ++++++++++++++++++ @@ -243,6 +259,12 @@ - Restore ``Schema.TYPE_MAPPING``, which was removed in 3.0.0b17 (:issue:`1012`). +Other changes: + +- *Backwards-incompatible*: ``_serialize`` and ``_deserialize`` methods of +all ``fields.Field`` subclasses must accept ``**kwargs`` (:pr:`1007`). + + 3.0.0b18 (2018-10-15) +++++++++++++++++++++ @@ -595,6 +617,13 @@ - Remove ``func`` parameter of ``fields.Function``. Remove ``method_name`` parameter of ``fields.Method`` (issue:`325`). Use the ``serialize`` parameter instead. - Remove ``extra`` parameter from ``Schema``. Use a ``@post_dump`` method to add additional data. +2.20.3 (2019-09-04) +******************* + +Bug fixes: + +- Don't swallow ``TypeError`` exceptions raised by ``Field._bind_to_schema`` or ``Schema.on_bind_field`` (:pr:`1376`). + 2.20.2 (2019-08-20) ******************* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/PKG-INFO new/marshmallow-3.0.3/PKG-INFO --- old/marshmallow-3.0.1/PKG-INFO 2019-08-21 19:56:22.000000000 +0200 +++ new/marshmallow-3.0.3/PKG-INFO 2019-09-05 03:44:12.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: marshmallow -Version: 3.0.1 +Version: 3.0.3 Summary: A lightweight library for converting complex datatypes to and from native Python datatypes. Home-page: https://github.com/marshmallow-code/marshmallow Author: Steven Loria @@ -187,7 +187,7 @@ Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Requires-Python: >=3.5 -Provides-Extra: docs Provides-Extra: tests -Provides-Extra: dev Provides-Extra: lint +Provides-Extra: docs +Provides-Extra: dev diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/docs/extending.rst new/marshmallow-3.0.3/docs/extending.rst --- old/marshmallow-3.0.1/docs/extending.rst 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/docs/extending.rst 2019-09-05 03:44:00.000000000 +0200 @@ -28,14 +28,14 @@ result = schema.load({"name": "Steve", "slug": "Steve Loria "}) result["slug"] # => 'steve-loria' - Passing "many" ++++++++++++++ -By default, pre- and post-processing methods receive one object/datum at a time, transparently handling the ``many`` parameter passed to the schema at runtime. +By default, pre- and post-processing methods receive one object/datum at a time, transparently handling the ``many`` parameter passed to the ``Schema``'s :func:`~marshmallow.Schema.dump`/:func:`~marshmallow.Schema.load` method at runtime. -In cases where your pre- and post-processing methods need to receive the input collection when ``many=True``, add ``pass_many=True`` to the method decorators. The method will receive the input data (which may be a single datum or a collection) and the boolean value of ``many``. +In cases where your pre- and post-processing methods needs to handle the input collection when processing multiple objects, add ``pass_many=True`` to the method decorators. +Your method will then receive the input data (which may be a single datum or a collection, depending on the dump/load call). Example: Enveloping +++++++++++++++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/docs/upgrading.rst new/marshmallow-3.0.3/docs/upgrading.rst --- old/marshmallow-3.0.1/docs/upgrading.rst 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/docs/upgrading.rst 2019-09-05 03:44:00.000000000 +0200 @@ -1041,6 +1041,29 @@ ``python-dateutil`` is no longer used by marshmallow. +Custom Fields +************* + +To make your custom fields compatible with marshmallow 3, ``_deserialize`` +should accept ``**kwargs``: + +.. code-block:: python + + from marshmallow import fields, ValidationError + from packaging import version + + # 2.x + class MyCustomField(fields.Field): + def _deserialize(self, value, attr, obj): + ... + + + # 3.x + class MyCustomField(fields.Field): + def _deserialize(self, value, attr, obj, **kwargs): + ... + + Upgrading to 2.3 ++++++++++++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/src/marshmallow/__init__.py new/marshmallow-3.0.3/src/marshmallow/__init__.py --- old/marshmallow-3.0.1/src/marshmallow/__init__.py 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/src/marshmallow/__init__.py 2019-09-05 03:44:00.000000000 +0200 @@ -13,7 +13,7 @@ from marshmallow.exceptions import ValidationError from distutils.version import LooseVersion -__version__ = "3.0.1" +__version__ = "3.0.3" __version_info__ = tuple(LooseVersion(__version__).version) __all__ = [ "EXCLUDE", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/src/marshmallow/decorators.py new/marshmallow-3.0.3/src/marshmallow/decorators.py --- old/marshmallow-3.0.1/src/marshmallow/decorators.py 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/src/marshmallow/decorators.py 2019-09-05 03:44:00.000000000 +0200 @@ -1,6 +1,17 @@ """Decorators for registering schema pre-processing and post-processing methods. These should be imported from the top-level `marshmallow` module. +Methods decorated with +`pre_load <marshmallow.decorators.pre_load>`, `post_load <marshmallow.decorators.post_load>`, +`pre_dump <marshmallow.decorators.pre_dump>`, `post_dump <marshmallow.decorators.post_dump>`, +and `validates_schema <marshmallow.decorators.validates_schema>` receive +``many`` as a keyword argument. In addition, `pre_load <marshmallow.decorators.pre_load>`, + `post_load <marshmallow.decorators.post_load>`, +and `validates_schema <marshmallow.decorators.validates_schema>` receive +``partial``. If you don't need these arguments, add ``**kwargs`` to your method +signature. + + Example: :: from marshmallow import ( @@ -14,7 +25,7 @@ age = fields.Integer(required=True) @post_load - def lowerstrip_email(self, item, **kwargs): + def lowerstrip_email(self, item, many, **kwargs): item['email'] = item['email'].lower().strip() return item @@ -71,9 +82,9 @@ ): """Register a schema-level validator. - By default, receives a single object at a time, regardless of whether ``many=True`` - is passed to the `Schema`. If ``pass_many=True``, the raw data (which may be a collection) - and the value for ``many`` is passed. + By default it receives a single object at a time, transparently handling the ``many`` + argument passed to the `Schema`'s :func:`~marshmallow.Schema.validate` call. + If ``pass_many=True``, the raw data (which may be a collection) is passed. If ``pass_original=True``, the original data (before unmarshalling) will be passed as an additional argument to the method. @@ -100,9 +111,9 @@ """Register a method to invoke before serializing an object. The method receives the object to be serialized and returns the processed object. - By default, receives a single object at a time, regardless of whether ``many=True`` - is passed to the `Schema`. If ``pass_many=True``, the raw data (which may be a collection) - and the value for ``many`` is passed. + By default it receives a single object at a time, transparently handling the ``many`` + argument passed to the `Schema`'s :func:`~marshmallow.Schema.dump` call. + If ``pass_many=True``, the raw data (which may be a collection) is passed. .. versionchanged:: 3.0.0 ``many`` is always passed as a keyword arguments to the decorated method. @@ -114,9 +125,9 @@ """Register a method to invoke after serializing an object. The method receives the serialized object and returns the processed object. - By default, receives a single object at a time, transparently handling the ``many`` - argument passed to the Schema. If ``pass_many=True``, the raw data - (which may be a collection) and the value for ``many`` is passed. + By default it receives a single object at a time, transparently handling the ``many`` + argument passed to the `Schema`'s :func:`~marshmallow.Schema.dump` call. + If ``pass_many=True``, the raw data (which may be a collection) is passed. If ``pass_original=True``, the original data (before serializing) will be passed as an additional argument to the method. @@ -131,9 +142,9 @@ """Register a method to invoke before deserializing an object. The method receives the data to be deserialized and returns the processed data. - By default, receives a single datum at a time, transparently handling the ``many`` - argument passed to the Schema. If ``pass_many=True``, the raw data - (which may be a collection) and the value for ``many`` is passed. + By default it receives a single object at a time, transparently handling the ``many`` + argument passed to the `Schema`'s :func:`~marshmallow.Schema.load` call. + If ``pass_many=True``, the raw data (which may be a collection) is passed. .. versionchanged:: 3.0.0 ``partial`` and ``many`` are always passed as keyword arguments to @@ -146,9 +157,11 @@ """Register a method to invoke after deserializing an object. The method receives the deserialized data and returns the processed data. - By default, receives a single datum at a time, transparently handling the ``many`` - argument passed to the Schema. If ``pass_many=True``, the raw data - (which may be a collection) and the value for ``many`` is passed. + See :ref:`examples <decorator_example>` for the method signature. + + By default it receives a single object at a time, transparently handling the ``many`` + argument passed to the `Schema`'s :func:`~marshmallow.Schema.load` call. + If ``pass_many=True``, the raw data (which may be a collection) is passed. If ``pass_original=True``, the original data (before deserializing) will be passed as an additional argument to the method. @@ -162,6 +175,7 @@ def set_hook(fn, key, **kwargs): """Mark decorated function as a hook to be picked up later. + You should not need to use this method directly. .. note:: Currently only works with functions and instance methods. Class and diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/src/marshmallow/fields.py new/marshmallow-3.0.3/src/marshmallow/fields.py --- old/marshmallow-3.0.1/src/marshmallow/fields.py 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/src/marshmallow/fields.py 2019-09-05 03:44:00.000000000 +0200 @@ -400,9 +400,7 @@ class Raw(Field): - """Field that applies no formatting or validation.""" - - pass + """Field that applies no formatting.""" class Nested(Field): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/src/marshmallow/schema.py new/marshmallow-3.0.3/src/marshmallow/schema.py --- old/marshmallow-3.0.1/src/marshmallow/schema.py 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/src/marshmallow/schema.py 2019-09-05 03:44:00.000000000 +0200 @@ -139,7 +139,7 @@ return dict_cls(inherited_fields + cls_fields) def __init__(cls, name, bases, attrs): - super().__init__(cls, bases, attrs) + super().__init__(name, bases, attrs) if name and cls.opts.register: class_registry.register(name, cls) cls._hooks = cls.resolve_hooks() @@ -348,8 +348,6 @@ usage is critical. Defaults to `True`. """ - pass - def __init__( self, *, @@ -505,7 +503,7 @@ value = field_obj.serialize(attr_name, obj, accessor=self.get_attribute) if value is missing: continue - key = field_obj.data_key or attr_name + key = field_obj.data_key if field_obj.data_key is not None else attr_name ret[key] = value return ret @@ -609,7 +607,9 @@ else: partial_is_collection = is_collection(partial) for attr_name, field_obj in self.load_fields.items(): - field_name = field_obj.data_key or attr_name + field_name = ( + field_obj.data_key if field_obj.data_key is not None else attr_name + ) raw_value = data.get(field_name, missing) if raw_value is missing: # Ignore missing field if we're allowed to. @@ -643,7 +643,7 @@ set_value(ret, key, value) if unknown != EXCLUDE: fields = { - field_obj.data_key or field_name + field_obj.data_key if field_obj.data_key is not None else field_name for field_name, field_obj in self.load_fields.items() } for key in set(data) - fields: @@ -914,9 +914,9 @@ fields_dict[field_name] = field_obj dump_data_keys = [ - obj.data_key or name - for name, obj in fields_dict.items() - if not obj.load_only + field_obj.data_key if field_obj.data_key is not None else name + for name, field_obj in fields_dict.items() + if not field_obj.load_only ] if len(dump_data_keys) != len(set(dump_data_keys)): data_keys_duplicates = { @@ -961,13 +961,12 @@ Also set field load_only and dump_only values if field_name was specified in ``class Meta``. """ + if field_name in self.load_only: + field_obj.load_only = True + if field_name in self.dump_only: + field_obj.dump_only = True try: - if field_name in self.load_only: - field_obj.load_only = True - if field_name in self.dump_only: - field_obj.dump_only = True field_obj._bind_to_schema(field_name, self) - self.on_bind_field(field_name, field_obj) except TypeError as error: # field declared as a class, not an instance if isinstance(field_obj, type) and issubclass(field_obj, base.FieldABC): @@ -977,6 +976,8 @@ 'Did you mean "fields.{}()"?'.format(field_name, field_obj.__name__) ) raise TypeError(msg) from error + raise error + self.on_bind_field(field_name, field_obj) @lru_cache(maxsize=8) def _has_processors(self, tag): @@ -1030,6 +1031,9 @@ '"{}" field does not exist.'.format(field_name) ) from error + data_key = ( + field_obj.data_key if field_obj.data_key is not None else field_name + ) if many: for idx, item in enumerate(data): try: @@ -1040,7 +1044,7 @@ validated_value = self._call_and_store( getter_func=validator, data=value, - field_name=field_obj.data_key or field_name, + field_name=data_key, error_store=error_store, index=(idx if self.opts.index_errors else None), ) @@ -1055,7 +1059,7 @@ validated_value = self._call_and_store( getter_func=validator, data=value, - field_name=field_obj.data_key or field_name, + field_name=data_key, error_store=error_store, ) if validated_value is missing: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/src/marshmallow.egg-info/PKG-INFO new/marshmallow-3.0.3/src/marshmallow.egg-info/PKG-INFO --- old/marshmallow-3.0.1/src/marshmallow.egg-info/PKG-INFO 2019-08-21 19:56:22.000000000 +0200 +++ new/marshmallow-3.0.3/src/marshmallow.egg-info/PKG-INFO 2019-09-05 03:44:12.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: marshmallow -Version: 3.0.1 +Version: 3.0.3 Summary: A lightweight library for converting complex datatypes to and from native Python datatypes. Home-page: https://github.com/marshmallow-code/marshmallow Author: Steven Loria @@ -187,7 +187,7 @@ Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Requires-Python: >=3.5 -Provides-Extra: docs Provides-Extra: tests -Provides-Extra: dev Provides-Extra: lint +Provides-Extra: docs +Provides-Extra: dev diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/tests/test_deserialization.py new/marshmallow-3.0.3/tests/test_deserialization.py --- old/marshmallow-3.0.1/tests/test_deserialization.py 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/tests/test_deserialization.py 2019-09-05 03:44:00.000000000 +0200 @@ -1285,6 +1285,13 @@ assert result["email"] == "[email protected]" assert "years" not in result + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + def test_deserialize_with_dump_only_param(self): class AliasingUserSerializer(Schema): name = fields.String() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/tests/test_fields.py new/marshmallow-3.0.3/tests/test_fields.py --- old/marshmallow-3.0.1/tests/test_fields.py 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/tests/test_fields.py 2019-09-05 03:44:00.000000000 +0200 @@ -174,14 +174,18 @@ class MySchema(Schema): foo = fields.List(fields.DateTime()) bar = fields.Tuple((fields.DateTime(),)) + baz = fields.List(fields.Date()) + qux = fields.Tuple((fields.Date(),)) class Meta: datetimeformat = "iso8601" dateformat = "iso8601" schema = MySchema() - assert schema.fields["foo"].inner.format == "iso8601" - assert schema.fields["bar"].tuple_fields[0].format == "iso8601" + for field_name in ("foo", "baz"): + assert schema.fields[field_name].inner.format == "iso8601" + for field_name in ("bar", "qux"): + assert schema.fields[field_name].tuple_fields[0].format == "iso8601" class TestMetadata: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/tests/test_schema.py new/marshmallow-3.0.3/tests/test_schema.py --- old/marshmallow-3.0.1/tests/test_schema.py 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/tests/test_schema.py 2019-09-05 03:44:00.000000000 +0200 @@ -551,6 +551,18 @@ BadUserSchema().dump(user) +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + @pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) def test_serializing_generator(SchemaClass): users = [User("Foo"), User("Bar")] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/marshmallow-3.0.1/tests/test_serialization.py new/marshmallow-3.0.3/tests/test_serialization.py --- old/marshmallow-3.0.1/tests/test_serialization.py 2019-08-21 19:56:09.000000000 +0200 +++ new/marshmallow-3.0.3/tests/test_serialization.py 2019-09-05 03:44:00.000000000 +0200 @@ -390,6 +390,13 @@ result = DumpToSchema().dump(data) assert result == {"NamE": "Richard", "YearS": 11} + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + schema.dump({"name": "Grace"}) == {"": "Grace"} + def test_serialize_with_attribute_and_data_key_uses_data_key(self): class ConfusedDumpToAndAttributeSerializer(Schema): name = fields.String(data_key="FullName")
