question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: Remove Nested(many=True) to keep only the List(Nested()) form

See original GitHub issue

See discussion in https://github.com/marshmallow-code/marshmallow/issues/493#issuecomment-380468027.

We have two ways to do the same thing. They sometimes behave differently, which generally means one of them is buggy.

IMHO, and from what I have seen from users around me, it is more natural for a new user to write List(Nested) than Nested(many). Besides, it is consistent with Dict(values=Nested).

I realize this is quite a breaking change, both from user perspective, because Nested(many=True) is probably the most commonly used form, and from developer perspective, because it involves a lot of code changes (but also a lot of code removal, which is nice).

There could be things that can be done with Nested(many=True) but not with List(Nested), because in the latter case, the nested Schema has access to the whole data, while in the former, it is called on each element. Perhaps some pre_load edge cases might suffer from the change. Any real-life example, anyone?

Anyway, since the question was raised in a comment in another issue, I figured I’d give it more visibility.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:13
  • Comments:39 (31 by maintainers)

github_iconTop GitHub Comments

3reactions
deckar01commented, Jul 15, 2019

I might try to dig into a perf dump and see where the time is going. That seems like a lot of time to just be caused by an extra layer of indirection. I wonder if Nested isn’t doing something it should be or if List is doing something it doesn’t need.

3reactions
sloriacommented, Jun 11, 2018

How would a self-referencing schema work with this? In other words, how would we express

friends = Nested('self', many=True, exclude=('friends',))
Read more comments on GitHub >

github_iconTop Results From Across the Web

jq: pick and remove nested fields - json - Stack Overflow
Create a fresh object (using {} ) when you want to pick, and use del when you want to remove. map({ "httpRequest": (...
Read more >
2025-nested-method-calls - The Rust RFC Book
Enable "nested method calls" where the outer call is an &mut self borrow, such as vec.push(vec.len()) (where vec: Vec<usize> ). This is done...
Read more >
Upgrading to Newer Releases — marshmallow 3.19.0 ...
Nested may take a callable that returns a schema instance. ... List(fields. ... When many=True , non-collection types are also considered invalid.
Read more >
JSON methods, toJSON - The Modern JavaScript Tutorial
The JSON (JavaScript Object Notation) is a general format to ... Here space = 2 tells JavaScript to show nested objects on multiple...
Read more >
[RFC PATCH v3 00/19] RFC: nested AVIC - public-inbox listing
[RFC PATCH v3 00/19] RFC: nested AVIC @ 2022-04-27 20:02 Maxim Levitsky ... r KVM: x86: SVM: remove avic's broken code that updated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found