marshmallow-code / marshmallow-code/marshmallow

[RFC] Don't pass attr, obj, data to fields (de)serialize methods

Open
#2,039 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backwards incompat feedback welcome
Dominant language
Python
Stars
7.2k
Forks
738
Avg merge
1d 23h
Merged PRs (30d)
7

Description

From a quick look, those are not used by existing fields. I suspect this might be or have been useful in specific fields such as `Method`.

I can't investigate this thoroughly right now and anyway that would be a breaking change, but opening this here for discussion.

For separation of concerns, (de)ser methods shouldn't need the parent obj/data and field name.

Also, this means that one needs an object and a field name to serialize some data with a field, which may not always be the case. They may pass `None` but then they don't respect the API (since it won't work with a field (de)ser method that actually relies on those). I faced this specific problem with `EnumValue` field, when building `self.choices`, see #2017.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named; start by tracing the field (de)serialize API and the EnumValue/self.choices use case described here, with related issue #2017. Done requires a decided compatibility scope for this proposed breaking change and agreement on how affected behavior will be covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.