473 Commits

Author SHA1 Message Date
guysz
b0a36d12e4
Fix compilation of fields with name identical to their type (#294)
* 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>
2021-12-01 16:31:02 +00:00
Kalan
a4d2d39546
Fix Python 3.9 Tests (#284)
Co-authored-by: James Hilton-Balfe <50501825+Gobot1234@users.noreply.github.com>
2021-11-19 21:32:36 +00:00
lazytype
c424b6f8db
Include AsyncIterator import for both clients and servers (#264)
Co-authored-by: Robin Lambertz <github@roblab.la>
2021-11-05 14:22:15 +00:00
James Hilton-Balfe
421fdba309
Allow parsing of messages from ByteStrings #266 2021-10-26 00:34:33 +01:00
Robin Lambertz
fb2793e0b6
Allow parsing messages from byteslike
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.
2021-08-25 12:53:02 +02:00
PIGNOSE
ad8b91766a
Add benchmarking cases for nested, repeat and deserialize (#241) 2021-06-21 23:38:22 +02:00
Bekhzod Tillakhanov
a33126544b
Fix readme docs 'Async gRPC Support' (#249) 2021-06-21 23:29:59 +02:00
nat
02e41afd09
Release v2.0.0b3 (#182)
Updated change log to include all new features and fixes from master.
v2.0.0b3
2021-04-07 12:57:44 +02:00
nat
7368299a70
Fix serialization of repeated fields with empty messages (#180)
Extend test config and utils to support exclusion of certain json samples from
testing for symetry.
2021-04-06 10:50:45 +10:00
nat
deb623ed14
Fix compilation of fields named 'bytes' or 'str' (#226)
* 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>
2021-04-06 10:45:57 +10:00
nat
95339bf74d
Misc cleanup, see commit body (#227)
- 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
2021-04-06 10:43:09 +10:00
nat
5b639c82b2
Micro-optimization: use tuples instead of lists for conditions (#228)
This should give a small speed boost to some critical code paths.
2021-04-06 10:40:45 +10:00
Matthew Badger
7c5ee47e68
Added support for infinite and nan floats/doubles (#215)
- 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)
2021-04-02 15:15:28 +02:00
Nat Noordanus
bb646fe26f Fix template bug resulting in empty __post_init__ methods 2021-04-02 10:13:08 +11:00
Nat Noordanus
fc90653ab1 Sort the list of sources in generated file headers 2021-04-02 10:13:00 +11:00
Nat Noordanus
2a73dbac98 Make plugin use betterproto generated classes internally
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
2021-04-02 10:13:00 +11:00
nat
891c9e5d6c
Update readme to avoid confusion about unreleased features. (#223) 2021-04-01 20:40:02 +02:00
Nat Noordanus
a890514b5c Update deps & add generate_lib task
- 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
2021-04-01 09:49:22 +11:00
Nat Noordanus
fe1e712fdb Make plugin use betterproto generated classes internally
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
2021-04-01 09:49:22 +11:00
Vasili Syrakis
7a358a63cf Add __version__ attribute to package 2021-03-31 11:44:32 +11:00
nat
342e6559dc
Properly serialize zero-value messages in a oneof group (#176)
Also improve test utils to make it easier to have multiple json examples.

Co-authored-by: Christopher Chambers <chris@peanutcode.com>
2021-03-15 13:52:35 +01:00
Vladimir Solomatin
2f62189346
Fix typing and datetime imports not being present for service method type annotations (#183) 2021-03-12 22:15:15 +01:00
MinJune Kim
8a215367ad
Allow empty services (#222)
Fixes issue #220
2021-03-12 21:49:58 +01:00
robinaly
6c1c41e9cc
Use dateutil parser (#213)
Switch to using `isoparse` from `dateutil.parser` instead of `datetime.fromisoformat` for more robust parsing of dates in from_dict.
2021-02-24 22:18:05 +01:00
Matthew Badger
9e6881999e
Add support for repeated timestamps and durations to to_dict from_dict (#211) 2021-02-16 19:54:50 +01:00
nat
59f5f88c0d
Rebuild poetry.lock to fix CI (#202) 2021-01-25 20:28:30 +01:00
Tim Schmidt
8eea5fe256
added documentation for server-facing stubs (#186) 2021-01-24 22:20:32 +01:00
Tim Schmidt
1d54ef8f99
Generate grpclib service stubs (#170) 2020-12-04 22:22:11 +01:00
nat
73cea12e1f
Fix incorrect routes in generated client when service is not in a package (#177) 2020-11-28 17:50:25 +01:00
Arun Babu Neelicattu
a157f05480
Release v2.0.0b2 (#175) v2.0.0b2 2020-11-24 23:04:33 +01:00
James
69dfe9cafc
Implement Message.__bool__ (#142)
* 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>
2020-11-24 19:35:09 +01:00
Arun Babu Neelicattu
a8a082e4e7
Update dependencies and add ci checks for python 3.9 (#173)
* Update locked dependencies to fix grpcio compile issue with python 3.9
* ci: add python 3.9
2020-11-24 19:28:28 +01:00
Tim Schmidt
e44de6da06
replace now-disabled set-env command (#172)
thanks @abn
2020-11-21 14:42:50 +01:00
James
a5e0ef910f
Fixes for Python 3.9 (#140)
Fix issue in logic for evaluating field types affecting python 3.9
2020-11-01 15:23:02 +01:00
James
8f7af272cc
QOL fixes (#141)
- Add missing type annotations
- Various style improvements
- Use constants more consistently
- enforce black on benchmark code
2020-10-17 19:27:11 +02:00
Arun Babu Neelicattu
bf9412e083
Use poetry-core as PEP 517 build backend (#108)
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.
2020-10-01 14:45:45 +02:00
Keerthan Jaic
4630c1cc67
bump grpclib to 0.4.1 (#150) 2020-09-23 21:55:23 +02:00
James
d3e4fbb311
Add Documentation (#125)
Add sphinx docs with readthedocs integration.

Docs can be built locally with `poe docs`.
2020-09-20 22:00:02 +02:00
Jonas Kalderstam
58556e0eb6
Update README with example of calling protoc from python (#149) 2020-09-19 17:03:49 +02:00
Adrian Garcia Badaracco
a3f5f21738
Add benchmarks (#148)
Add asv based benchmarks to guide future optimisation work.
2020-09-19 16:28:16 +02:00
Arun Babu Neelicattu
0028cc384a
Relax black version constraints (#146)
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.
2020-08-31 22:10:57 +02:00
Chris Chambers
034e2e7da0
Add support for recursive messages (#130)
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>
2020-08-30 21:04:36 +02:00
James
ca16b6ed34
Various micro-optimizations (#139) 2020-08-30 17:23:57 +02:00
James
16d554db75
Update black 2020-08-29 17:15:59 +02:00
Adrian Garcia Badaracco
9ef5503728
Small improvements to models.py 2020-08-23 14:26:15 +02:00
Adrian Garcia Badaracco
c93351ef21
Factor code template compilation out into a separate module 2020-08-09 20:06:39 +02:00
James
80bef7c94f
Improve logic to avoid keyword collisions in generated code
Use the standard library keyword module instead of a hard coded list and applying it to enum keys as well.
2020-08-09 12:41:41 +02:00
nat
804805f0f5
Update poe (#132)
- This update improves support for windows & removes the direct dependency on poetry
2020-08-06 22:16:25 +02:00
Arun Babu Neelicattu
43c134d27c
ci: refactor jobs and improve platform coverage (#128) 2020-07-30 14:47:38 +02:00
Arun Babu Neelicattu
0cd9510b54
Support deprecated message and fields (#126) 2020-07-30 14:47:01 +02:00