Skip to content

Allow enum attributes to be set to their values #173

@olliesilvester

Description

@olliesilvester

The Enum DataType currently doesn't have its own validate function, so it uses the default default parent validation which errors if not isinstance(value, self.dtype). This means if I have an enum like

Class MyEnum(Enum):
    MY_VAL = "Val"

then the only values that are accepted when doing a put into an attribute of this type are instances of this enum. For instance, I can do await attr.set(MyEnum.MY_VAL), but not `await attr.set("Val").

It would be useful to extend this validation so that we can set these attributes to their enum values.

Acceptance Criteria

  • Add a validation function to the enum datatype to allow enum members to be used in the set
  • No breaking changes occur - you can still use set with enum instances as before

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