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

enum_union #31

Open
rtviii opened this issue Dec 20, 2023 · 5 comments
Open

enum_union #31

rtviii opened this issue Dec 20, 2023 · 5 comments

Comments

@rtviii
Copy link
Owner

rtviii commented Dec 20, 2023

This gives me a lot of headaches with serialization (value != name of the enum members), but is a really good sell in organizing the PolymerTypes. What is the essential functionality of it over the vanilla python Enum? Can is be replaced? Trying with pydantic.Enum.

@rtviii
Copy link
Owner Author

rtviii commented Dec 21, 2023

members=  [*map( lambda x: x.value, [*Polynucleotide] )]
print(members)
x = "5SrRNA" in members
print(x)
['mt12SrRNA', 'mt16SrRNA', '5SrRNA', '16SrRNA']
True

@rtviii
Copy link
Owner Author

rtviii commented Dec 22, 2023

TODO : Investigate whether enum_union can be rewritten in terms of pydantic.RootModel

@rtviii
Copy link
Owner Author

rtviii commented Dec 23, 2023

the serialiazation solution for now is

    @field_serializer('nomenclature')
    def serialize_dt(self, nomenclature:list[PolymerClass], _info):
        return [x.name for x in nomenclature]
        ```

@rtviii rtviii closed this as completed Jun 3, 2024
@rtviii rtviii reopened this Jun 3, 2024
@rtviii
Copy link
Owner Author

rtviii commented Jun 16, 2024

It's been a good run of reckless arrogance and folly, but enum.StrEnum ships with python3.11 so there is no reason to indulge in this masochism any further

@rtviii
Copy link
Owner Author

rtviii commented Jun 16, 2024

  • Replace with enum.StrEnum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant