-
Notifications
You must be signed in to change notification settings - Fork 233
map enum int's into python enums (#157) #273
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
Conversation
Fallback to int like before, not really happy with this but no other idea.
For the default enum handling I had to add a fallback to int like it was before, in case the enum class does not have a value defined for
|
I think this approach is not ideal. Before this PR, python-betterproto generates types that it doesn't respect. E.G. it may generate code like: class TestEnum(betterproto.Enum):
ZERO = 0
ONE = 1
@dataclass
class Foo(betterproto.Message):
bar: TestEnum = betterproto.enum_field(1) But when parsing With this PR, the behavior is changed so
I think both of those are suboptimal. The first case means we still lie to the type system, and the second goes directly against the Proto3 Language Guide:
What I think would work best would be to change |
I 100% agree with you @roblabla. I already experimented with this approach but could not get it to work properly. |
I might be able to help in the enums department and whip out an old PR or 2 and make a custom implementation for Enum which is more open (and more performant). |
Hi, thanks for creating this PR. I'm using a hacky workaround for mapping deserialized ints to enum but this would be much better. Any update on when this PR will be ready to merge? |
I'm going to give @roblabla's suggestion of implementing Enum as an open set a go hopefully over the weekend with these changes included. |
Hi @Gobot1234. Any progress on this? |
I have the changes implemented I just need to make a pr |
Closing this in favour of #293 |
This maps deserialized enum integers into real python enum instances.
Closes #157, #169