You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Proposing the following 2 changes to fields.Nested:
(1) drop support for passing callables that return schema classes and dicts (e.g. lambda: CSchema) and only support callables that return instances (lambda: CSchema()).
It would vastly both the usage and the internal implementation of Nested. This eliminates a class of bugs where the nested argument conflicts with only, exclude, many, and unknown.
I agree it is strange to accept an instance and modifiers applying to that instance. I don't like modifying instances. This is something we may want to prevent (#1281).
But it may be useful for nested schemas passed by name as string, or by class. (I don't see the point of accepting a class, we could require an instance, but I see the point of accepting a schema name as string, which ultimately falls in the same case as a class).
Regarding schemas passed as callable, it may be surprising that only instances are accepted, but if it makes our job easier, I don't mind dropping the class case and require an instance. Doing the instantiation in the callable is not too much to ask. (We never accepted a callable returning a schema name as string, anyway.)
Proposing the following 2 changes to
fields.Nested
:(1) drop support for passing callables that return schema classes and dicts (e.g.
lambda: CSchema
) and only support callables that return instances (lambda: CSchema()
).Before:
After:
And (2) deprecate the
only
,exclude
,many
, andunknown
parameters ofNested
.Final end state of
fields.Nested
would beWhy?
It would vastly both the usage and the internal implementation of
Nested
. This eliminates a class of bugs where thenested
argument conflicts withonly
,exclude
,many
, andunknown
.See #2165 for an example of this.
The text was updated successfully, but these errors were encountered: