danielgtaylor / danielgtaylor/python-betterproto
Disappears from the generated `ServiceBase` if there is a `ID` in the name [2.0.0b3]
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 234
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
## Env
Python: 3.9
protoc: 3.15.6
betterproto: 2.0.0b3
OS: linux
---
### Given proto
```proto
syntax = "proto3";
package com.test.v1;
import "google/protobuf/empty.proto";
service TestService {
rpc Test(PublisherUserID) returns (google.protobuf.Empty);
}
message PublisherUserID {
int64 publisher_user_id = 1;
}
```
### Generated `TestServiceBase`
Parameter `PublisherUserID` of `test()` disappered.
```py3
class TestServiceBase(ServiceBase):
async def test(self) -> "betterproto_lib_google_protobuf.Empty":
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
async def __rpc_test(self, stream: grpclib.server.Stream) -> None:
request = await stream.recv_message()
request_kwargs = {}
response = await self.test(**request_kwargs)
await stream.send_message(response)
def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
return {
"/com.test.v1.TestService/Test": grpclib.const.Handler(
self.__rpc_test,
grpclib.const.Cardinality.UNARY_UNARY,
PublisherUserId,
betterproto_lib_google_protobuf.Empty,
),
}
```
---
### Midified proto
Rename `ID` to `Id`
```proto
syntax = "proto3";
package com.test.v1;
import "google/protobuf/empty.proto";
service TestService {
rpc Test(PublisherUserId) returns (google.protobuf.Empty);
}
message PublisherUserId {
int64 publisher_user_id = 1;
}
```
### Generated `TestServiceBase`
```py3
class TestServiceBase(ServiceBase):
async def test(
self, publisher_user_id: int
) -> "betterproto_lib_google_protobuf.Empty":
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
async def __rpc_test(self, stream: grpclib.server.Stream) -> None:
request = await stream.recv_message()
request_kwargs = {
"publisher_user_id": request.publisher_user_id,
}
response = await self.test(**request_kwargs)
await stream.send_message(response)
def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
return {
"/com.test.v1.TestService/Test": grpclib.const.Handler(
self.__rpc_test,
grpclib.const.Cardinality.UNARY_UNARY,
PublisherUserId,
betterproto_lib_google_protobuf.Empty,
),
}
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Usa le definizioni proto fornite e confronta l'output generato di TestServiceBase per PublisherUserID e PublisherUserId. Inizia dal punto di ingresso del generatore che produce il metodo del servizio e request_kwargs, quindi aggiungi un caso di regressione che copra la forma dell'ID. Il lavoro è completato quando il metodo generato mantiene publisher_user_id e lo passa attraverso request_kwargs.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100