Compare commits
9 Commits
v2.0.0b1
...
michael-sa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c02d1b21a | ||
|
|
ac32bcd25a | ||
|
|
72855227bd | ||
|
|
47081617c2 | ||
|
|
d734206fe5 | ||
|
|
bbf40f9694 | ||
|
|
6671d87cef | ||
|
|
cd66b0511a | ||
|
|
c48ca2e386 |
22
CHANGELOG.md
22
CHANGELOG.md
@@ -5,28 +5,6 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
- Versions suffixed with `b*` are in `beta` and can be installed with `pip install --pre betterproto`.
|
|
||||||
|
|
||||||
## [2.0.0b1] - 2020-07-04
|
|
||||||
|
|
||||||
[Upgrade Guide](./docs/upgrading.md)
|
|
||||||
|
|
||||||
> Several bugfixes and improvements required or will require small breaking changes, necessitating a new version.
|
|
||||||
> `2.0.0` will be released once the interface is stable.
|
|
||||||
|
|
||||||
- Add support for gRPC and **stream-stream** [#83](https://github.com/danielgtaylor/python-betterproto/pull/83)
|
|
||||||
- Switch from to `poetry` for development [#75](https://github.com/danielgtaylor/python-betterproto/pull/75)
|
|
||||||
- Fix No arguments are generated for stub methods when using import with proto definition
|
|
||||||
- Fix two packages with the same name suffix should not cause naming conflict [#25](https://github.com/danielgtaylor/python-betterproto/issues/25)
|
|
||||||
|
|
||||||
- Fix Import child package from root [#57](https://github.com/danielgtaylor/python-betterproto/issues/57)
|
|
||||||
- Fix Import child package from package [#58](https://github.com/danielgtaylor/python-betterproto/issues/58)
|
|
||||||
- Fix Import parent package from child package [#59](https://github.com/danielgtaylor/python-betterproto/issues/59)
|
|
||||||
- Fix Import root package from child package [#60](https://github.com/danielgtaylor/python-betterproto/issues/60)
|
|
||||||
- Fix Import root package from root [#61](https://github.com/danielgtaylor/python-betterproto/issues/61)
|
|
||||||
|
|
||||||
- Fix ALL_CAPS message fields are parsed incorrectly. [#11](https://github.com/danielgtaylor/python-betterproto/issues/11)
|
|
||||||
|
|
||||||
## [1.2.5] - 2020-04-27
|
## [1.2.5] - 2020-04-27
|
||||||
|
|
||||||
- Add .j2 suffix to python template names to avoid confusing certain build tools [#72](https://github.com/danielgtaylor/python-betterproto/pull/72)
|
- Add .j2 suffix to python template names to avoid confusing certain build tools [#72](https://github.com/danielgtaylor/python-betterproto/pull/72)
|
||||||
|
|||||||
33
README.md
33
README.md
@@ -40,7 +40,7 @@ This project exists because I am unhappy with the state of the official Google p
|
|||||||
|
|
||||||
This project is a reimplementation from the ground up focused on idiomatic modern Python to help fix some of the above. While it may not be a 1:1 drop-in replacement due to changed method names and call patterns, the wire format is identical.
|
This project is a reimplementation from the ground up focused on idiomatic modern Python to help fix some of the above. While it may not be a 1:1 drop-in replacement due to changed method names and call patterns, the wire format is identical.
|
||||||
|
|
||||||
## Installation
|
## Installation & Getting Started
|
||||||
|
|
||||||
First, install the package. Note that the `[compiler]` feature flag tells it to install extra dependencies only needed by the `protoc` plugin:
|
First, install the package. Note that the `[compiler]` feature flag tells it to install extra dependencies only needed by the `protoc` plugin:
|
||||||
|
|
||||||
@@ -52,12 +52,6 @@ pip install "betterproto[compiler]"
|
|||||||
pip install betterproto
|
pip install betterproto
|
||||||
```
|
```
|
||||||
|
|
||||||
*Betterproto* is under active development. To install the latest beta version, use `pip install --pre betterproto`.
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
### Compiling proto files
|
|
||||||
|
|
||||||
Now, given you installed the compiler and have a proto file, e.g `example.proto`:
|
Now, given you installed the compiler and have a proto file, e.g `example.proto`:
|
||||||
|
|
||||||
```protobuf
|
```protobuf
|
||||||
@@ -155,7 +149,7 @@ service Echo {
|
|||||||
|
|
||||||
You can use it like so (enable async in the interactive shell first):
|
You can use it like so (enable async in the interactive shell first):
|
||||||
|
|
||||||
```python
|
```py
|
||||||
>>> import echo
|
>>> import echo
|
||||||
>>> from grpclib.client import Channel
|
>>> from grpclib.client import Channel
|
||||||
|
|
||||||
@@ -180,8 +174,8 @@ Both serializing and parsing are supported to/from JSON and Python dictionaries
|
|||||||
|
|
||||||
For compatibility the default is to convert field names to `camelCase`. You can control this behavior by passing a casing value, e.g:
|
For compatibility the default is to convert field names to `camelCase`. You can control this behavior by passing a casing value, e.g:
|
||||||
|
|
||||||
```python
|
```py
|
||||||
MyMessage().to_dict(casing=betterproto.Casing.SNAKE)
|
>>> MyMessage().to_dict(casing=betterproto.Casing.SNAKE)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Determining if a message was sent
|
### Determining if a message was sent
|
||||||
@@ -306,22 +300,7 @@ datetime.datetime(2019, 1, 1, 11, 59, 58, 800000, tzinfo=datetime.timezone.utc)
|
|||||||
|
|
||||||
Join us on [Slack](https://join.slack.com/t/betterproto/shared_invite/zt-f0n0uolx-iN8gBNrkPxtKHTLpG3o1OQ)!
|
Join us on [Slack](https://join.slack.com/t/betterproto/shared_invite/zt-f0n0uolx-iN8gBNrkPxtKHTLpG3o1OQ)!
|
||||||
|
|
||||||
### Requirements
|
First, make sure you have Python 3.6+ and `poetry` installed, along with the official [Protobuf Compiler](https://github.com/protocolbuffers/protobuf/releases) for your platform. Then:
|
||||||
|
|
||||||
- Python (3.6 or higher)
|
|
||||||
|
|
||||||
- [protoc](https://grpc.io/docs/protoc-installation/) (3.12 or higher)
|
|
||||||
*Needed to compile `.proto` files and run the tests*
|
|
||||||
|
|
||||||
- [poetry](https://python-poetry.org/docs/#installation)
|
|
||||||
*Needed to install dependencies in a virtual environment*
|
|
||||||
|
|
||||||
- make ([ubuntu](https://www.howtoinstall.me/ubuntu/18-04/make/), [windows](https://stackoverflow.com/questions/32127524/how-to-install-and-use-make-in-windows), [mac](https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/))
|
|
||||||
|
|
||||||
*Needed to conveniently run development tasks.*
|
|
||||||
*Alternatively, manually run the commands defined in the [Makefile](./Makefile)*
|
|
||||||
|
|
||||||
### Setup
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Get set up with the virtual env & dependencies
|
# Get set up with the virtual env & dependencies
|
||||||
@@ -331,7 +310,7 @@ poetry install
|
|||||||
poetry shell
|
poetry shell
|
||||||
```
|
```
|
||||||
|
|
||||||
Run `make help` to see all available development tasks.
|
To benefit from the collection of standard development tasks ensure you have make installed and run `make help` to see available tasks.
|
||||||
|
|
||||||
### Code style
|
### Code style
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ xfail = {
|
|||||||
"namespace_keywords", # 70
|
"namespace_keywords", # 70
|
||||||
"namespace_builtin_types", # 53
|
"namespace_builtin_types", # 53
|
||||||
"googletypes_struct", # 9
|
"googletypes_struct", # 9
|
||||||
"googletypes_value", # 9,
|
"googletypes_value", # 9
|
||||||
|
"enum_skipped_value", # 93
|
||||||
"import_capitalized_package",
|
"import_capitalized_package",
|
||||||
"example", # This is the example in the readme. Not a test.
|
"example", # This is the example in the readme. Not a test.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
message Test {
|
||||||
|
enum MyEnum {
|
||||||
|
ZERO = 0;
|
||||||
|
ONE = 1;
|
||||||
|
// TWO = 2;
|
||||||
|
THREE = 3;
|
||||||
|
FOUR = 4;
|
||||||
|
}
|
||||||
|
MyEnum x = 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
from betterproto.tests.output_betterproto.enum_skipped_value import (
|
||||||
|
Test,
|
||||||
|
TestMyEnum,
|
||||||
|
)
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail(reason="#93")
|
||||||
|
def test_message_attributes():
|
||||||
|
assert (
|
||||||
|
Test(x=TestMyEnum.ONE).to_dict()["x"] == "ONE"
|
||||||
|
), "MyEnum.ONE is not serialized to 'ONE'"
|
||||||
|
assert (
|
||||||
|
Test(x=TestMyEnum.THREE).to_dict()["x"] == "THREE"
|
||||||
|
), "MyEnum.THREE is not serialized to 'THREE'"
|
||||||
|
assert (
|
||||||
|
Test(x=TestMyEnum.FOUR).to_dict()["x"] == "FOUR"
|
||||||
|
), "MyEnum.FOUR is not serialized to 'FOUR'"
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# Upgrade Guide
|
|
||||||
|
|
||||||
## [1.2.5] to [2.0.0b1]
|
|
||||||
|
|
||||||
### Updated package structures
|
|
||||||
|
|
||||||
Generated code now strictly follows the *package structure* of the `.proto` files.
|
|
||||||
Consequently `.proto` files without a package will be combined in a single `__init__.py` file.
|
|
||||||
To avoid overwriting existing `__init__.py` files, its best to compile into a dedicated subdirectory.
|
|
||||||
|
|
||||||
Upgrading:
|
|
||||||
|
|
||||||
- Remove your previously compiled `.py` files.
|
|
||||||
- Create a new *empty* directory, e.g. `generated` or `lib/generated/proto` etcetera.
|
|
||||||
- Regenerate your python files into this directory
|
|
||||||
- Update import statements, e.g. `import ExampleMessage from generated`
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "betterproto"
|
name = "betterproto"
|
||||||
version = "2.0.0b1"
|
version = "1.2.5"
|
||||||
description = "A better Protobuf / gRPC generator & library"
|
description = "A better Protobuf / gRPC generator & library"
|
||||||
authors = ["Daniel G. Taylor <danielgtaylor@gmail.com>"]
|
authors = ["Daniel G. Taylor <danielgtaylor@gmail.com>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
Reference in New Issue
Block a user