Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add **kwargs to load() for marshmallow-sqlalchemy #111

Merged
merged 5 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
---------

2.1.0 (unreleased)
++++++++++++++++++

Features:

- Pass ``**kwargs`` to inner schemas (#108).
Thanks @fuhrysteve for the PR.

2.0.1 (2019-07-14)
++++++++++++++++++

Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions marshmallow_oneofschema/one_of_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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:
Expand All @@ -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()
Expand All @@ -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})

Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
envlist=
lint
check-build
py{35,36,37}
py{35,36,37,38}

[testenv]
extras = tests
Expand Down