Closed AdrienVannson closed 1 month ago
I forget to mention: this problem makes some of the tests from test_inputs.py
fail. The problem only appears when plugin_output_package
is manually set to "tests.output_betterproto_pydantic"
, which is not the case by default. Once this problem (and at least another one) is fixed, I will send a PR to also execute the input tests with Pydantic.
I forget to mention: this problem makes some of the tests from
test_inputs.py
fail. The problem only appears whenplugin_output_package
is manually set to"tests.output_betterproto_pydantic"
, which is not the case by default. Once this problem (and at least another one) is fixed, I will send a PR to also execute the input tests with Pydantic.
That would be a huge help actually
Need this fix. Hoping it can be released in the near future.
I would like to fix a few small problems before, but it should not take long. Once this is merged, I think we can release a new version. In the meantime, you can use the last version on master, which should work fine.
Summary
Fix https://github.com/danielgtaylor/python-betterproto/issues/604
Methods such as
parse
are often called on a new object:value = cls().parse(value)
. However, is the message contains oneof fields, this used to make the validator_validate_field_groups
fail when using pydantic.I removed the check that at least one value of the
oneof
is defined. This is coherent with gRPC's documentation: "If you have a message with many fields and where at most one field will be set at the same time, you can enforce this behavior and save memory by using the oneof feature." and "You can check which value in a oneof is set (if any) using a special case() or WhichOneof() method"Checklist