Skip to content

Marshmallow warnings #328

Open
Open
@reikje

Description

@reikje

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?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions