RFC: Remove Nested(many=True) to keep only the List(Nested()) form
See original GitHub issueSee 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:
- Created 5 years ago
- Reactions:13
- Comments:39 (31 by maintainers)
Top GitHub Comments
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 ifList
is doing something it doesn’t need.How would a self-referencing schema work with this? In other words, how would we express