python-betterproto icon indicating copy to clipboard operation
python-betterproto copied to clipboard

fix: Message.to_pydict and .from_pydict

Open RF-Tar-Railt opened this issue 1 year ago • 4 comments

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, ...)

RF-Tar-Railt avatar Sep 06 '24 19:09 RF-Tar-Railt

What is this fixing? Please can you also provide tests so that this doesn't happen in the future

Gobot1234 avatar Sep 06 '24 19:09 Gobot1234

What is this fixing? Please can you also provide tests so that this doesn't happen in the future

updated

RF-Tar-Railt avatar Sep 06 '24 19:09 RF-Tar-Railt

Could a reviewer please take a look at this? It makes protobufs containing oneof unusable with v2.0.0b7.

straygar avatar Dec 02 '24 15:12 straygar

@cetanu Thx for reviewing! When do branches get merged?

straygar avatar Jan 24 '25 11:01 straygar