473 Commits

Author SHA1 Message Date
Arun Babu Neelicattu
beafc812ff
Fix static type checking for grpclib client (#124)
* Fix static type checking in grpclib client
* Fix python3.6 compatibility issue with dataclasses
2020-07-30 11:30:58 +02:00
Arun Babu Neelicattu
3d8c0cb713
grpclib_client: handle trailer-only responses (#127)
Resolves: #123
2020-07-25 19:57:46 +02:00
nat
c513853301
Replace Makefile with poe tasks in pyproject.yaml (#118)
https://github.com/nat-n/poethepoet
2020-07-25 19:54:40 +02:00
Brady Kieffer
c1a76a5f5e
Serialize default values in oneofs when calling to_dict() or to_json() (#110)
* 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
2020-07-25 19:51:40 +02:00
Joshua Salzedo
2745953a8e
Fix the readme gRPC usage example (#122)
* re-implement README gRPC client example to be a self-contained script
 - fix a syntax error
 - fix a usage error

* asyncio.run() was added in 3.7
 - this lib targets >= 3.6

* Apply suggestions from code review

Optimized imports, store RPC call result before printing

Co-authored-by: Arun Babu Neelicattu <arun.neelicattu@gmail.com>

* add entry-point check to example

Co-authored-by: Arun Babu Neelicattu <arun.neelicattu@gmail.com>
2020-07-25 19:45:26 +02:00
Adrian Garcia Badaracco
b5dcac1250
REF: Refactor plugin.py to use modular dataclasses in tree-like structure to represent parsed data (#121)
Refactor plugin to parse input into data-class based hierarchical structure
2020-07-25 19:44:02 +02:00
James
cbd3437080
Some minor consistency changes
- replace some usages of `==` with `is`
- use available constants instead of magic strings for type names

Co-authored-by: nat <nat.noordanus@gmail.com>
2020-07-12 16:07:27 +02:00
boukeversteegh
2585a07fcf Improve poetry install speed by first upgrading pip 2020-07-12 15:42:31 +02:00
Bouke Versteegh
6c29771f4c
Fix: to_dict returns wrong enum fields when numbering is not consecutive (#102)
Fixes #93 to_dict returns wrong enum fields when numbering is not consecutive
2020-07-12 15:06:55 +02:00
Arun Babu Neelicattu
0ba0692dec Handle mutable default arguments cleanly
When generating code, ensure that default list/dict arguments are
initialised in local scope if unspecified or `None`.
2020-07-11 22:33:44 +02:00
Arun Babu Neelicattu
42e197f985 Ensure we clean up egg-info directories 2020-07-11 19:51:01 +02:00
Arun Babu Neelicattu
459d12b24d Move betterproto → src/betterproto
This change avoids some nasty import issues and also ensures that the
right code is tested and arbitrary code is not included when packaging.
2020-07-11 19:51:01 +02:00
Arun Babu Neelicattu
cebf9176a3 Move betterproto/tests → tests 2020-07-11 19:51:01 +02:00
Bouke Versteegh
8864f4fdbd
Merge pull request #103 from boukeversteegh/fix/service-input-message
Fix - No arguments are generated for stub methods when using `import` with proto definition
2020-07-10 22:55:05 +02:00
Arun Babu Neelicattu
03211604bc Replace dependency on protoc with grpcio-tools
This change removes the dependency on platform provided protobuf tools
in favour of `grpcio-tools` dependency. This makes both development and
compiler use independent from platform dependencies.
2020-07-10 13:16:40 +02:00
boukeversteegh
1d7ba850e9 Reorder methods, use BETTERPROTO_DUMP for dump env var, docs. 2020-07-09 23:09:34 +02:00
Bouke Versteegh
b2651335ce
Merge pull request #112 from danielgtaylor/pr/readme-contribution
Updated readme with contribution section. More help welcome 😃
2020-07-09 22:53:22 +02:00
nat
5a591ef2a4
Add link to testing README in CONTRIBUTING.md 2020-07-09 20:41:13 +02:00
boukeversteegh
8d7d0efb9b Move contributing guide to CONTRIBUTING.md 2020-07-09 09:31:04 +02:00
boukeversteegh
b891d257f6 Updated readme with contribution section. More help welcome 😃 2020-07-09 00:16:36 +02:00
Bouke Versteegh
8bcb67b66f
Merge pull request #81 from discord/serialized_on_wire_repeated
Always set serialized_on_wire for all parsed message fields
2020-07-08 23:10:14 +02:00
boukeversteegh
72d72b4603 Merge remote-tracking branch 'daniel/master' into fix/service-input-message
# Conflicts:
#	betterproto/plugin.py
2020-07-08 23:00:32 +02:00
Bouke Versteegh
3273ae4d2c
Merge pull request #100 from boukeversteegh/fix/circular-dependencies
Import bug - Circular Dependencies
2020-07-07 21:45:06 +02:00
Bouke Versteegh
6fe666473d
Merge pull request #106 from abn/minor-formatting
Minor non-functional improvements
2020-07-07 20:22:44 +02:00
Arun Babu Neelicattu
0338fcba29 Ignore commonly used .venv directory 2020-07-07 19:23:38 +02:00
Arun Babu Neelicattu
0f3ad25770 Minor non-functional changes
- fix few typos
- remove unused imports
- fix minor code-quality issues
- replace `grpclib._protocols` with `grpclib._typing`
- fix boolean and None assertions in test cases
2020-07-07 19:23:38 +02:00
Bouke Versteegh
586e28d2dc
Merge pull request #104 from abn/fix-casing
Add missing async/await keywords when casing
2020-07-07 14:32:51 +02:00
Arun Babu Neelicattu
a8d8159d27 Add missing async/await keywords when casing 2020-07-07 13:15:46 +02:00
boukeversteegh
3f519d4fb1 Fixes #23 again, a broken test made it seem the issue was fixed before. 2020-07-05 17:14:53 +02:00
boukeversteegh
dedead048f Read proto objects before services 2020-07-05 13:10:25 +02:00
boukeversteegh
87b3a4b86d Move parsing of protobuf data types and services into separate methods 2020-07-05 12:27:06 +02:00
boukeversteegh
f2e87192b0 Clarify variable names 2020-07-05 12:24:21 +02:00
boukeversteegh
98d00f0d21 Supports running plugin.py standalone by reading from a dump-file, so its possible to debug it. 2020-07-05 12:20:55 +02:00
Bouke Versteegh
bde6d06835
Merge pull request #99 from boukeversteegh/release-v2.0.0b1
Release v2.0.0b1
v2.0.0b1
2020-07-05 10:20:37 +02:00
boukeversteegh
23dcbc2695 Fixes circular import problem when a non-circular dependency triangle is flattened into two python packages 2020-07-04 15:49:55 +02:00
boukeversteegh
0af0cf4bfb Fixes circular import problem when a non-circular dependency triangle is flattened into two python packages 2020-07-04 15:35:42 +02:00
boukeversteegh
eaa4f7f5d9 Release v2.0.0b1 2020-07-04 14:00:35 +02:00
Bouke Versteegh
cdddb2f42a
Merge pull request #88 from boukeversteegh/fix/imports
🍏 Fix imports
2020-07-04 11:22:12 +02:00
boukeversteegh
d21cd6e391 black 2020-07-01 13:15:03 +02:00
boukeversteegh
af7115429a Expose betterproto.ServiceStub 2020-07-01 12:43:28 +02:00
boukeversteegh
0d9387abec Remove stringcase dependency 2020-07-01 12:43:12 +02:00
boukeversteegh
f4ebcb0f65 Merge remote-tracking branch 'daniel/master' into fix/imports
# Conflicts:
#	Pipfile
#	README.md
#	betterproto/__init__.py
#	betterproto/plugin.py
#	betterproto/tests/util.py
2020-07-01 12:19:25 +02:00
boukeversteegh
81711d2427 Avoid naming conflicts when importing multiple types with the same name from an ancestor package 2020-07-01 12:07:59 +02:00
boukeversteegh
e3135ce766 Add parameter for non-strict cased output that preserves delimiter count 2020-07-01 09:39:37 +02:00
Bouke Versteegh
9532844929
Merge pull request #83 from nat-n/client-streaming
Client streaming
2020-06-24 22:13:54 +02:00
nat
0c5d1ff868
Merge branch 'master' into client-streaming 2020-06-23 22:02:23 +02:00
Bouke Versteegh
5fb4b4b7ff
Merge pull request #75 from nat-n/add_poetry
Switch from pipenv to poetry
2020-06-23 21:59:46 +02:00
Nat Noordanus
4f820b4a6a Include python 3.8 i ci test runs & optimise CI and make config 2020-06-22 19:38:41 +02:00
Nat Noordanus
75a4c230da Add optional deps to dev-deps
So contributors dont have to remember to run poetry install with `-E compiler`
2020-06-22 19:35:23 +02:00
nat
5c9a12e2f6 Merge pull request #1 from boukeversteegh/client-streaming-tests
Client streaming tests
2020-06-16 19:36:40 +02:00