aind-data-schema icon indicating copy to clipboard operation
aind-data-schema copied to clipboard

Enum-like classes cant be used as dictionary keys

Open bruno-f-cruz opened this issue 9 months ago • 13 comments

Not sure if there is a different intended use...

To reproduce:

from aind_data_schema_models.platforms import Platform
from pydantic import BaseModel


class Foo(BaseModel):
    platform: dict[Platform.ONE_OF, str]


foo = Foo(platform={Platform.BEHAVIOR: "foo"})
print(foo)

bar = foo.model_dump()

bruno-f-cruz avatar Jun 03 '24 21:06 bruno-f-cruz