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

Marshmallow warnings #328

Open
reikje opened this issue Jan 5, 2022 · 4 comments · May be fixed by #351
Open

Marshmallow warnings #328

reikje opened this issue Jan 5, 2022 · 4 comments · May be fixed by #351
Assignees

Comments

@reikje
Copy link

reikje commented Jan 5, 2022

Trying to get rid of a number of warnings that started to show up when running my test suite. I am running:

  • pytest 5.4.3
  • dataclasses-json 0.5.6
  • marshmallow 3.14.1
  • marshmallow-enum 1.5.1

This is test that can be used as repo:

from dataclasses import dataclass
from typing import Optional, List

from dataclasses_json import dataclass_json, Undefined


@dataclass_json(undefined=Undefined.EXCLUDE)
@dataclass
class LineItem:
    sku: str
    quantity: int


@dataclass_json(undefined=Undefined.EXCLUDE)
@dataclass
class Fulfillment:
    id: int
    line_items: Optional[List[LineItem]] = None


class TestWarning:
    def test_marshmallow_warnings(self):
        fulfillments = Fulfillment.schema().loads('''
            [
                {"id": 1, "line_items": null}, 
                {"id": 2, "line_items": null}
            ]''', many=True)

These are the warnings:

=============================== warnings summary ===============================
test_marshallow_warning.py::TestWarning::test_marshallow_warning
  .../lib/python3.8/site-packages/marshmallow/fields.py:218: RemovedInMarshmallow4Warning: Passing field metadata as keyword arguments is deprecated. Use the explicit `metadata=...` argument instead. Additional metadata: {'field_many': False}
    warnings.warn(

test_marshallow_warning.py::TestWarning::test_marshallow_warning
  .../lib/python3.8/site-packages/marshmallow/fields.py:173: RemovedInMarshmallow4Warning: The 'default' argument to fields is deprecated. Use 'dump_default' instead.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/latest/warnings.html
======================== 1 passed, 2 warnings in 0.04s =========================

Found a few suggestions for people having the same issue but nothing seemed to work. How should I rewrite my dataclass?

@corporate-gadfly
Copy link

Marshmallow pull request.

@LondonAppDev
Copy link

@corporate-gadfly Maybe I'm missing something, but I don't think that PR is relevant to this? This is an issue about deprecation warnings for Marshmallow 4 which should be fixed in the dataclasses-json package?

@zyv
Copy link

zyv commented Feb 4, 2022

I think this is a duplicate of #276.

@stevenpackardblp
Copy link

I think this is a duplicate of #276.

This is slightly different. These warnings were introduced with marshmallow-code/marshmallow#1742 and released in Marshmallow 3.13.0. #276 is a deprecation warning in Marshallow for a different option name introduced in Marshmallow 3.10.0.

stevenpackardblp added a commit to stevenpackardblp/dataclasses-json that referenced this issue Apr 9, 2022
In Marshmallow 3.13.0, the `default` and `missing` parameters of the
`Field` object were deprecated and replaced with `dump_default` and
`load_default` respectively. As these are new parameters added in
version 3.13.0, the minimum version requirement is bumped accordingly.

fixes: lidatong#328
@matt035343 matt035343 self-assigned this Jul 22, 2023
stevenpackardblp added a commit to stevenpackardblp/dataclasses-json that referenced this issue Feb 2, 2024
In Marshmallow 3.13.0, the `default` and `missing` parameters of the
`Field` object were deprecated and replaced with `dump_default` and
`load_default` respectively.

fixes: lidatong#328
stevenpackardblp added a commit to stevenpackardblp/dataclasses-json that referenced this issue May 8, 2024
In Marshmallow 3.13.0, the `default` and `missing` parameters of the
`Field` object were deprecated and replaced with `dump_default` and
`load_default` respectively.

fixes: lidatong#328
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants