danielgtaylor / danielgtaylor/python-betterproto

Capitalized (Title case) package name causes invalid gRPC code generation

Aperta
#272 0 commenti 4 reazioni 0 assegnatari Vedi su GitHub
compiler-bug
Lingua principale
Python
Stelle
1.8k
Fork
234
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Working with gRPC on `v2.0.0b3`, if the `.proto` package name starts with a capital letter, e.g.
``` proto
package Echo;
```
Then the generated file becomes significantly different and invalid. Most obviously there is `from .. import MessageName as _MessageName__` for the message types and it can't be imported.

For example, take the `echo.proto` example from the README.md and generate as suggested with `python -m grpc_tools.protoc -I . --python_betterproto_out=. echo.proto`, it seems fine, but edit it to `package Echo;` and in `Echo/__init__.py` you get, among other changes not limited to `s/echo/Echo`, at the end:

``` py
from .. import EchoEchoRequest as _EchoEchoRequest__
from .. import EchoEchoResponse as _EchoEchoResponse__
from .. import EchoEchoStreamResponse as _EchoEchoStreamResponse__
```

These don't exist, and the package can't be imported.

Found in `v2.0.0b3`. Thanks!

----
For completeness, here's the problematic `.proto`
``` proto
syntax = "proto3";

package Echo;

message EchoRequest {
string value = 1;
// Number of extra times to echo
uint32 extra_times = 2;
}

message EchoResponse {
repeated string values = 1;
}

message EchoStreamResponse {
string value = 1;
}

service Echo {
rpc Echo(EchoRequest) returns (EchoResponse);
rpc EchoStream(EchoRequest) returns (stream EchoStreamResponse);
}
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.