materialsproject / emmet

Be a master builder of databases of material properties. Avoid the Kragle.
https://materialsproject.github.io/emmet/
Other
51 stars 63 forks source link

Replace `emmet.core.utils.ValueEnum` with std lib `enum.StrEnum` #917

Closed janosh closed 2 months ago

janosh commented 6 months ago

In case I missed something, @munrojm was there a reason not to use enum.StrEnum?

I was seeing JSON serialization errors with the atomate2 PhononMaker's pydantic model which don't occur with enum.StrEnum.

 json.dump(atomate2_phonon_doc, json_file, cls=MontyEncoder)

Update

Didn't realize StrEnum is 3.11+ only. We could use a backport package like https://github.com/irgeek/StrEnum.

munrojm commented 6 months ago

I have no issues with using a backport package for now.

Andrew-S-Rosen commented 4 months ago

@janosh, I believe your issues may have been addressed in #944.

janosh commented 4 months ago

thanks @Andrew-S-Rosen, good to know.

probably still makes sense to define a

class StrEnum(str, Enum)

to enforce string values certain enums in emmet until oldest python supported is 3.11.