danielgtaylor / danielgtaylor/python-betterproto
default value in oneof content
- Lenguaje dominante
- Python
- Estrellas
- 1.8k
- Forks
- 234
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
Línea de trabajo
Reproduce el problema usando el esquema oneof mostrado y las llamadas a to_dict(betterproto.Casing.SNAKE, ...) de betterproto. Compara la salida con el comportamiento oficial de MessageToJson, centrándote en si se emiten los miembros oneof no establecidos. Se considera terminado cuando la serialización incluye únicamente el miembro fixed_gate seleccionado y conserva los campos esperados que no son oneof.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend-api-design
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100