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.
It's convenient for
GroupSpecandArraySpecto haveattributesdefault to the empty dict, and similarly forGroupSpec.members. The problem with an empty dict as a default is that it's not generally valid for all models -- if someone defines aGroupSpecwhere 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 baseGroupSpec/ArraySpec, I think it's correct forattributesandmembersto require explicit initialization.That being said, I think it would be very useful to have a subclass of
GroupSpecwhereattributesandmembersdo default to the empty dict (probably viaField(default_factory=dict). Not sure what to call this class though --SimpleGroupSpec?RawGroupSpec? Open to ideas.