-
Notifications
You must be signed in to change notification settings - Fork 5
Description
It's convenient for GroupSpec and ArraySpec to have attributes default to the empty dict, and similarly for GroupSpec.members. The problem with an empty dict as a default is that it's not generally valid for all models -- if someone defines a GroupSpec where the members are modelled by a typeddict with required keys, then the empty dict is not a safe default any more, and it might not be possible to define a safe default that isn't nonsense. So for the base GroupSpec / ArraySpec, I think it's correct for attributes and members to require explicit initialization.
That being said, I think it would be very useful to have a subclass of GroupSpec where attributes and members do default to the empty dict (probably via Field(default_factory=dict). Not sure what to call this class though -- SimpleGroupSpec? RawGroupSpec? Open to ideas.