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
Yes, the dynamic-valued Enum has an odd implementation. It basically disables the validate method and handles the validation in an ad hoc manner in the setter, which is not what is used when it's an inner trait inside of List.
pzahemszky
changed the title
Lists of Enums can contain anything
List of dynamic Enums can contain anything
Sep 17, 2019
As Robert was saying, this issue only affects dynamic-valued Enums:
fromtraits.apiimportHasTraits, Enum, Listvals= ["a", "b"]
classMyClass(HasTraits):
list_enum=List(Enum(vals))
my_obj=MyClass()
my_obj.list_enum= ["c", None, MyClass()]
# traits.trait_errors.TraitError: Each element of the 'list_enum' trait# of a MyClass instance must be 'a' or 'b', but a value of 'c'# <class 'str'> was specified
Traits 5.1.2-1
MWE:
The text was updated successfully, but these errors were encountered: