* if you have a field named "bytes" using the bytes type, it doesn't work.
* Enable existing use-case & generalize solution to cover it
Co-authored-by: Spencer <spencer@sf-n.com>
- Enable oneof_enum test case that passes now (removed the xfail)
- Switch from toml to tomlkit as a dev dep for better toml support
- upgrade poethepoet to latest stable release
- use full table format for poe tasks to avoid long lines in pyproject.toml
- remove redundant _WrappedMessage class
- fix various Mypy warnings
- reformat some comments for consistent line length
- Added support for the custom double values from
the protobuf json spec: "Infinity", "-Infinity", and "NaN"
- Added `infinite_floats` test data
- Updated Message.__eq__ to consider nan values
equal
- Updated `test_message_json` and
`test_binary_compatibility` to replace NaN float
values in dictionaries before comparison
(because two NaN values are not equal)
This means the betterproto plugin no longer needs to depend durectly on
protobuf.
This requires a small runtime hack to monkey patch some google types to
get around the fact that the compiler uses proto2, but betterproto
expects proto3.
Also:
- regenerate google.protobuf package
- fix a regex bug in the logic for determining whether to use a google
wrapper type.
- fix a bug causing comments to get mixed up when multiple proto files
generate code into a single python module
- Remove plugin dependency on protobuf since it's no longer required.
- Update poethepoet to for better pyproject toml syntax support
- Add handy generate_lib poe task for maintaining generated libs
This means the betterproto plugin no longer needs to depend durectly on
protobuf.
This requires a small runtime hack to monkey patch some google types to
get around the fact that the compiler uses proto2, but betterproto
expects proto3.
Also:
- regenerate google.protobuf package
- fix a regex bug in the logic for determining whether to use a google
wrapper type.
- fix a bug causing comments to get mixed up when multiple proto files
generate code into a single python module
Changes message initialization (`__post_init__`) so that default values
are no longer eagerly created to prevent infinite recursion when
initializing recursive messages.
As a result, `PLACEHOLDER` will be present in the message for any
uninitialized fields. So, an implementation of `__get_attribute__` is
added that checks for `PLACEHOLDER` and lazily creates and stores
default field values.
And, because `PLACEHOLDER` values don't compare equal with zero values,
a custom implementation of `__eq__` is provided, and the code generation
template is updated so that messages generate with `@dataclass(eq=False)`.
Also add new Message __repr__ implementation that skips PLACEHOLDER
values and orders keys by number from the proto.
Co-authored-by: Christopher Chambers <chris@peanutcode.com>
Co-authored-by: nat <n@natn.me>
Co-authored-by: James <50501825+Gobot1234@users.noreply.github.com>
* Serialize default values in oneofs when calling to_dict() or to_json()
This change is consistent with the official protobuf implementation. If
a default value is set when using a oneof, and then a message is
translated from message -> JSON -> message, the default value is kept in
tact. Also, if no default value is set, they remain null.
* Some cleanup + testing for nested messages with oneofs
* Cleanup oneof_enum test cases, they should be fixed
This _should_ address:
https://github.com/danielgtaylor/python-betterproto/issues/63
* Include default value oneof fields when serializing to bytes
This will cause oneof fields with default values to explicitly be sent
to clients. Note that does not mean that all fields are serialized and
sent to clients, just those that _could_ be null and are not.
* Remove assignment when populating a sub-message within a proto
Also, move setattr out one indentation level
* Properly transform proto with empty string in oneof to bytes
Also, updated tests to ensure that which_one_of picks up the set field
* Formatting betterproto/__init__.py
* Adding test cases demonstrating equivalent behaviour with google impl
* Removing a temporary file I made locally
* Adding some clarifying comments
* Fixing tests for python38