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

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

Open
woodgear opened this issue Sep 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@woodgear
Copy link

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

@woodgear woodgear added the bug Something isn't working label Sep 21, 2024
rianwouters added a commit to rianwouters/dataclasses-json that referenced this issue Oct 25, 2024
The 'default' argument to fields is deprecated in Marshmallow. Use 'dump_default' instead.

Solves lidatong#546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant