Skip to content

default members and attributes #133

@d-v-b

Description

@d-v-b

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions