-
Notifications
You must be signed in to change notification settings - Fork 229
Fix: to_dict returns wrong enum fields when numbering is not consecutive #102
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
Fix: to_dict returns wrong enum fields when numbering is not consecutive #102
Conversation
…ng is not consecutive
dee034f
to
a945246
Compare
src/betterproto/__init__.py
Outdated
if field_is_repeated: | ||
enum_class = field_type.__args__[0] | ||
if isinstance(value, typing.Iterable): | ||
output[cased_name] = [ | ||
enum_class(element).name for element in value | ||
] | ||
else: | ||
warnings.warn( | ||
f"Non-iterable value for repeated enum field {field_name}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual fix is here ☝️
…ive (danielgtaylor#102) Fixes danielgtaylor#93 to_dict returns wrong enum fields when numbering is not consecutive
Thanks for this bug fix! I just ran into this myself and it took me a while to realize the fix was available in version 2. Any when this will come out of beta? |
No but if you want this fix install betterproto==2.0.0b2 |
closes #93
Enum()
constructor, instead of index.