marshmallow-code / marshmallow-code/marshmallow

fields.Nested should optionally pass the parent object to the Nested Schema

Open
#940 12 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

As described in #900, there is no obvious way to create a nested serialization from a flat object. To fix this, fields.Nested should accept an optional from_parent argument. When true, the nested Schema is passed the parent object rather than the attribute at the field name. from_parent will default to False, which will maintain current behavior.

Any feedback on this idea? I plan on implementing it soon.

Thanks,
James

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

Read issue #900 first, then locate the fields.Nested implementation and its schema-handling path. Confirm how the parent object and field-name attribute are currently passed, then identify the existing tests covering Nested behavior; done means an optional from_parent=True path works while the default preserves current behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.