Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

janosh
Copy link
Member

@janosh janosh commented Jan 1, 2024

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.

ValueEnum causes JSON serialization bug in pydantic model
json.dump(atomate2_phonon_doc, json_file, cls=MontyEncoder)
@janosh janosh added Core Any updates for Emmet-Core CLI Any updates for Emmet-CLI Builders Any updates for Emmet-Builders pydantic pydantic-related PRs and issues serialization Related to JSON and other serialization formats labels Jan 2, 2024
@munrojm
Copy link
Member

munrojm commented Jan 3, 2024

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

@Andrew-S-Rosen
Copy link
Member

Andrew-S-Rosen commented Feb 22, 2024

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

@janosh
Copy link
Member Author

janosh commented Feb 22, 2024

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.

@janosh janosh closed this May 1, 2024
@janosh janosh deleted the str-enum-over-value-enum branch May 1, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Builders Any updates for Emmet-Builders CLI Any updates for Emmet-CLI Core Any updates for Emmet-Core pydantic pydantic-related PRs and issues serialization Related to JSON and other serialization formats
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants