Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Add a default values for rpc with empty message

Aberta
#613 1 comentário 2 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
grpc, python

Direção de pesquisa

Nenhum arquivo ou teste é identificado na issue. Comece localizando as assinaturas dos métodos RPC de Python gerados e o tratamento atual de google.protobuf.Empty ou de mensagens sem campos; o trabalho estará concluído quando RPCs de mensagens vazias puderem ser chamados sem um argumento, enquanto as chamadas existentes com mensagens explícitas continuarem funcionando.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

enhancement
The Problem

Sometimes, it is needed to declare RPCs that take no parameter. However, it is not possible in gRPC. In such a situation, it is needed to either create an empty message type, or to use google.protobuf.Empty ( https://stackoverflow.com/questions/29687243/protobuf-rpc-service-method-without-parameters ).

However, this is not convenient for the final user: an empty message need to be created and passed to the method each time. It also makes it necessary to add potentially long imports.

The Ideal Solution

To make this easier, it would be better to add a default value for the parameter containing the request when it is possible. I see two possibilities:

  • Add the default value only for google.protobug.Empty
  • Add the default value for all the messages who have no field at all

I think the second solution would be better as it is common to define empty messages in such situations. I can make a PR if you agree, I already have a working version locally.

The Current Solution

Currently, it is necessary for the user to import by hand from betterproto.lib.std.google.protobuf import Empty or the custom message, which is not convenient.

The feature would turn:

from betterproto.lib.std.google.protobuf import Empty
answer = TestStub().call(Empty())

To something like:

answer = TestStub().call()
Linguagem predominante
Python
Estrelas
1.8k
Forks
235
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de danielgtaylor/python-betterproto

Todas as issues de danielgtaylor/python-betterproto

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.