* Revert "Fix compilation of fields named 'bytes' or 'str' (#226)"
This reverts commit deb623ed14cea65f0a0d17e9c770426d71198ae0.
* Fix compilation of fileds with name identical to their type
* Added test for field-name identical to python type
Co-authored-by: Guy Szweigman <guysz@nvidia.com>
Byteslike objects (like memoryview) do not have a decode function defined.
Instead, a string may be created from them by passing them to the str
constructor along with an encoding.
* 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
* Implement Message.__bool__ with similar semantics to a collection, such that any value being set on the message (i.e. having a non-default value) make the Message value truthy .
Co-authored-by: nat <n@natn.me>
This change replaces the use of poetry as the build backend in favour
of the leaner poetry-core. This speeds up PEP-517 builds for source
installs, tox environment setup etc.
This change ensures that the wheel built only requests for the minimum
version of black it requires to function as intended. Without this
change any project that uses betterproto[compiler] would break while
resolving dependencies.
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>