python-betterproto
python-betterproto copied to clipboard
fix: Message.to_pydict and .from_pydict
Summary
resolve #610
Just one line different:
-
to_dict:
try:
value = getattr(self, field_name)
except AttributeError:
value = self._get_field_default(field_name)
cased_name = casing(field_name).rstrip("_") # type: ignore
-
to_pydict:
value = getattr(self, field_name)
cased_name = casing(field_name).rstrip("_") # type: ignore
from_pydict is the same cause.
Checklist
- [x] If code changes were made then they have been tested.
- [ ] I have updated the documentation to reflect the changes.
- [x] This PR fixes an issue.
- [ ] This PR adds something new (e.g. new method or parameters).
- [ ] This change has an associated test.
- [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
- [ ] This PR is not a code change (e.g. documentation, README, ...)
What is this fixing? Please can you also provide tests so that this doesn't happen in the future
What is this fixing? Please can you also provide tests so that this doesn't happen in the future
updated
Could a reviewer please take a look at this? It makes protobufs containing oneof unusable with v2.0.0b7.
@cetanu Thx for reviewing! When do branches get merged?