From c1b97444c83a506146c717c71c701e9018142051 Mon Sep 17 00:00:00 2001 From: "Stephen J. Fuhry" Date: Tue, 17 Mar 2020 13:52:49 +0000 Subject: [PATCH 1/4] add **kwargs to load() for marshmallow-sqlalchemy This is particularly to help support polymorphic fields in sqlalchemy See: https://github.com/marshmallow-code/marshmallow-oneofschema/issues/108 --- marshmallow_oneofschema/one_of_schema.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/marshmallow_oneofschema/one_of_schema.py b/marshmallow_oneofschema/one_of_schema.py index 5b58727..e9993f7 100644 --- a/marshmallow_oneofschema/one_of_schema.py +++ b/marshmallow_oneofschema/one_of_schema.py @@ -109,7 +109,7 @@ def _dump(self, obj, *, update_fields=True, **kwargs): result[self.type_field] = obj_type return result - def load(self, data, *, many=None, partial=None, unknown=None): + def load(self, data, *, many=None, partial=None, unknown=None, **kwargs): errors = {} result_data = [] result_errors = {} @@ -119,7 +119,7 @@ def load(self, data, *, many=None, partial=None, unknown=None): if not many: try: result = result_data = self._load( - data, partial=partial, unknown=unknown + data, partial=partial, unknown=unknown, **kwargs ) # result_data.append(result) except ValidationError as error: @@ -128,7 +128,7 @@ def load(self, data, *, many=None, partial=None, unknown=None): else: for idx, item in enumerate(data): try: - result = self._load(item, partial=partial) + result = self._load(item, partial=partial, **kwargs) result_data.append(result) except ValidationError as error: result_errors[idx] = error.normalized_messages() @@ -143,7 +143,7 @@ def load(self, data, *, many=None, partial=None, unknown=None): exc = ValidationError(errors, data=data, valid_data=result) raise exc - def _load(self, data, *, partial=None, unknown=None): + def _load(self, data, *, partial=None, unknown=None, **kwargs): if not isinstance(data, dict): raise ValidationError({"_schema": "Invalid data type: %s" % data}) @@ -173,7 +173,7 @@ def _load(self, data, *, partial=None, unknown=None): schema.context.update(getattr(self, "context", {})) - return schema.load(data, many=False, partial=partial, unknown=unknown) + return schema.load(data, many=False, partial=partial, unknown=unknown, **kwargs) def validate(self, data, *, many=None, partial=None): try: From 0b2a669666248f23d8ba84a6fee4840604f1098d Mon Sep 17 00:00:00 2001 From: "Stephen J. Fuhry" Date: Tue, 17 Mar 2020 13:56:56 +0000 Subject: [PATCH 2/4] add python 3.8 to the build --- azure-pipelines.yml | 4 ++-- setup.py | 1 + tox.ini | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f8f5658..b7bbb33 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,11 +15,11 @@ resources: jobs: - template: job--python-tox.yml@sloria parameters: - toxenvs: [lint, py35, py36, py37, check-build] + toxenvs: [lint, py35, py36, py37, py38, check-build] os: linux - template: job--pypi-release.yml@sloria parameters: - python: "3.7" + python: "3.8" distributions: "sdist bdist_wheel" dependsOn: - tox_linux diff --git a/setup.py b/setup.py index aa38a9f..3a730e1 100644 --- a/setup.py +++ b/setup.py @@ -47,5 +47,6 @@ def read(fname): "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", ], ) diff --git a/tox.ini b/tox.ini index 757b2c3..3a70a03 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ envlist= lint check-build - py{35,36,37} + py{35,36,37,38} [testenv] extras = tests From 85771a300ce9a971113551ca177f8a4f67bea18f Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Mon, 5 Oct 2020 23:18:07 -0400 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9e98080..ce8119d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,14 @@ Changelog --------- +2.1.0 (unreleased) +++++++++++++++++++ + +Features: + +- Pass ``**kwargs`` to inner schemas (#111). + Thanks @fuhrysteve for the PR. + 2.0.1 (2019-07-14) ++++++++++++++++++ From edb4077471b1a7712bafc9b0e6ce2bb4f20fd2b0 Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Mon, 5 Oct 2020 23:19:17 -0400 Subject: [PATCH 4/4] Fix issue number --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ce8119d..cfc6995 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,7 +6,7 @@ Changelog Features: -- Pass ``**kwargs`` to inner schemas (#111). +- Pass ``**kwargs`` to inner schemas (#108). Thanks @fuhrysteve for the PR. 2.0.1 (2019-07-14)