danielgtaylor / danielgtaylor/python-betterproto

Importing well known types

Đang mở
#9 11 bình luận 9 reaction 1 người được giao Được @boukeversteegh nhận Xem trên GitHub
bug has test medium medium priority
Ngôn ngữ chính
Python
Star
1.8k
Fork
234
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hello,

I'm not sure how to work with well known types.

Having a proto file like this:

```
syntax = "proto3";

package simple;

import "google/protobuf/empty.proto";

service SimpleSender {
rpc Send(SendParams) returns (google.protobuf.Empty) {}
}

message SendParams {
string body = 1;
}
```

I get output like this:

```python
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: Simple.proto
# plugin: python-betterproto
from dataclasses import dataclass

import betterproto
import grpclib

from .google import protobuf


@dataclass
class SendParams(betterproto.Message):
body: str = betterproto.string_field(1)


class SimpleSenderStub(betterproto.ServiceStub):
async def send(self, *, body: str = "") -> protobuf.Empty:
request = SendParams()
request.body = body

return await self._unary_unary(
"/simple.SimpleSender/Send", request, protobuf.Empty,
)
```

There is ofcourse no `google` package. I tried to generate code from proto files included in `grpc_tools` but I'm not able to get any python code.

What is the best way to work with well known types?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.