danielgtaylor / danielgtaylor/python-betterproto
default value in oneof content
- Linguagem predominante
- Python
- Estrelas
- 1.8k
- Forks
- 234
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
oneof op {
FixedGate fixedGate = 1;
RotationGate rotationGate = 2;
CustomizedGate customizedGate = 3;
CompositeGate compositeGate = 4;
string procedureName = 5;
Measure measure = 6;
bool barrier = 7;
}
enum FixedGate {
// 1 bit
ID = 0;
X = 1;
Y = 2;
Z = 3;
H = 4;
S = 5;
SDG = 6;
T = 7;
TDG = 8;
// 2 bit
CX = 9;
CY = 10;
CZ = 11;
CH = 12;
SWAP = 13;
// 3 bit
CCX = 14;
CSWAP = 15;
}
enum RotationGate {
// 1 bit
U = 0; // Universal rotation
RX = 1;
RY = 2;
RZ = 3;
// 2 bit
CU = 4;
CRX = 5;
CRY = 6;
CRZ = 7;
}
message CustomizedGate {
Matrix matrix = 1;
}
I only set fixed_gate = 'ID'
betterproto:
json.dumps(msg.to_dict(betterproto.Casing.SNAKE, False))
{# nothing
"q_reg_list": [
1
]
},
json.dumps(msg.to_dict(betterproto.Casing.SNAKE, True))
{
"fixed_gate": "ID", # oneof default value
"rotation_gate": "U", # oneof default value
"customized_gate": {, # oneof default value
"matrix": {
"shape": [],
"array": []
}
},
"composite_gate": "RZZ", # oneof default value
"procedure_name": "", # oneof default value
"measure": { # oneof default value
"type": "X",
"c_reg_list": []
},
"barrier": false, # oneof default value
"q_reg_list": [
1
],
"argument_value_list": [],
"argument_id_list": []
},
official
MessageToJson(pbObj, preserving_proto_field_name=False)
{
"fixedGate": "ID", # oneof default value
"qRegList": [
1
],
"argumentValueList": [],
"argumentIdList": []
},
MessageToJson(pbObj, preserving_proto_field_name=True)
{
"fixedGate": "ID", # oneof default value
"qRegList": [
1
]
},
The official is right
Guia de contribuição
Direção de pesquisa
Reproduza o problema usando o esquema oneof mostrado e as chamadas de to_dict(betterproto.Casing.SNAKE, ...) do betterproto. Compare a saída com o comportamento oficial de MessageToJson, concentrando-se em saber se membros oneof não definidos são emitidos. A tarefa estará concluída quando a serialização incluir somente o membro fixed_gate selecionado, mantendo os campos esperados que não são oneof.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- backend-api-design
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100