Skip to content

[BUG] RemovedInMarshmallow4Warning: The 'default' argument to fields is deprecated. Use 'dump_default' instead. #546

Open
@woodgear

Description

@woodgear

Description

it seems Marshmallow want to use dump_default or load_default instead of just default .
the follow code will warning like

.venv/lib/python3.12/site-packages/dataclasses_json/mm.py:277: RemovedInMarshmallow4Warning: The 'default' argument to fields is deprecated. Use 'dump_default' instead.

Code snippet that reproduces the issue

from dataclasses import dataclass, field
from dataclasses_json import DataClassJsonMixin
@dataclass
class A(DataClassJsonMixin):
    data_list: list[str] = field(default_factory=lambda: [])
    xx: str = ""

def test_dataclass():
    a = A(data_list=["a", "b", "c"])
    print(a)
    a_json = a.to_json()
    print(a_json)
    na = A.schema().loads(a_json)

Describe the results you expected

no warnning

Python version you are using

Python 3.12.5

Environment description

apsw==3.46.1.0
certifi==2024.8.30
charset-normalizer==3.3.2
dataclasses-json==0.6.7
idna==3.10
iniconfig==2.0.0
invoke==2.2.0
jsondiff==2.0.0
marshmallow==3.22.0
marshmallow_dataclass==8.7.1
mypy==1.11.2
mypy-extensions==1.0.0
packaging==24.1
pluggy==1.5.0
pytest==8.2.2
PyYAML==6.0.2
requests==2.32.3
shortuuid==1.0.13
typeguard==4.3.0
typing-inspect==0.9.0
typing_extensions==4.12.2
urllib3==2.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions