Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Fixed marshmallow 3.x deprecation warnings #422

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Contributors (chronological)
- Areeb Jamal `@iamareebjamal <https://github.com/iamareebjamal>`_
- Suren Khorenyan `@mahenzon <https://github.com/mahenzon>`_
- Karthikeyan Singaravelan `@tirkarthi <https://github.com/tirkarthi>`_
- Vlad Munteanu `@vladmunteanu https://github.com/vladmunteanu/`
8 changes: 6 additions & 2 deletions marshmallow_jsonapi/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ def schema(self):

def get_related_url(self, obj):
if self.related_url:
params = resolve_params(obj, self.related_url_kwargs, default=self.default)
params = resolve_params(
obj, self.related_url_kwargs, default=self.dump_default
)
non_null_params = {
key: value for key, value in params.items() if value is not None
}
Expand All @@ -162,7 +164,9 @@ def get_related_url(self, obj):

def get_self_url(self, obj):
if self.self_url:
params = resolve_params(obj, self.self_url_kwargs, default=self.default)
params = resolve_params(
obj, self.self_url_kwargs, default=self.dump_default
)
non_null_params = {
key: value for key, value in params.items() if value is not None
}
Expand Down
2 changes: 1 addition & 1 deletion marshmallow_jsonapi/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(

def get_url(self, obj, view_name, view_kwargs):
if view_name:
kwargs = resolve_params(obj, view_kwargs, default=self.default)
kwargs = resolve_params(obj, view_kwargs, default=self.dump_default)
kwargs["endpoint"] = view_name
try:
return flask.url_for(**kwargs)
Expand Down
5 changes: 1 addition & 4 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Meta:

class PostSchema(Schema):
id = fields.Str()
post_title = fields.Str(attribute="title", dump_to="title", data_key="title")
post_title = fields.Str(attribute="title", data_key="title")

author = fields.Relationship(
"http://test.test/posts/{id}/author/",
Expand All @@ -114,8 +114,6 @@ class PostSchema(Schema):
"http://test.test/posts/{id}/comments/",
related_url_kwargs={"id": "<id>"},
attribute="comments",
load_from="post-comments",
dump_to="post-comments",
data_key="post-comments",
schema="CommentSchema",
many=True,
Expand All @@ -126,7 +124,6 @@ class PostSchema(Schema):
"http://test.test/posts/{id}/keywords/",
related_url_kwargs={"id": "<id>"},
attribute="keywords",
dump_to="post-keywords",
data_key="post-keywords",
schema="KeywordSchema",
many=True,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def test_empty_relationship_with_alternative_identifier_field(
field = Relationship(
related_url="/authors/{author_id}",
related_url_kwargs={"author_id": "<author.last_name>"},
default=None,
dump_default=None,
)
result = field.serialize("author", post_with_null_author)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PostAuthorFlaskSchema(Schema):
field = Relationship(
related_view="author_detail",
related_view_kwargs={"author_id": "<author.last_name>"},
default=None,
dump_default=None,
)

class Meta:
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_empty_relationship_with_alternative_identifier_field(
field = Relationship(
related_view="author_detail",
related_view_kwargs={"author_id": "<author.last_name>"},
default=None,
dump_default=None,
)
result = field.serialize("author", post_with_null_author)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Meta:
class AuthorSchemaWithOverrideInflection(Schema):
id = fields.Str(dump_only=True)
# data_key and load_from takes precedence over inflected attribute
first_name = fields.Str(data_key="firstName", load_from="firstName")
first_name = fields.Str(data_key="firstName")
last_name = fields.Str()

class Meta:
Expand Down
7 changes: 3 additions & 4 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class PostClassSchema(PostSchema):
"http://test.test/posts/{id}/comments/",
related_url_kwargs={"id": "<id>"},
attribute="comments",
dump_to="post-comments",
data_key="post-comments",
schema=CommentSchema,
many=True,
)
Expand Down Expand Up @@ -306,7 +306,6 @@ class PostInnerSchemalessSchema(Schema):
"http://test.test/posts/{id}/comments/",
related_url_kwargs={"id": "<id>"},
data_key="post-comments",
load_from="post-comments",
many=True,
type_="comments",
)
Expand Down Expand Up @@ -834,14 +833,14 @@ class ArticleMissingParamSchema(Schema):
include_resource_linkage=True,
many=False,
type_="people",
missing="1",
load_default="1",
)
comments = fields.Relationship(
dump_only=False,
include_resource_linkage=True,
many=True,
type_="comments",
missing=["2", "3"],
load_default=["2", "3"],
)

class Meta:
Expand Down