Implementation of `has` macro is incomplete
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comienza con la implementación de has en src/celpy/evaluation.py, alrededor de la línea 1273, y luego sigue cómo MessageType representa los campos protobuf omitidos y los que tienen valores predeterminados. Reproduce el comportamiento informado con un ejemplo mínimo de protobuf antes de elegir un enfoque; se considera terminado cuando has sigue las reglas de presencia documentadas de proto2 y proto3 sin confundir los valores predeterminados con campos establecidos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The has macro is implemented by visiting the child nodes and returning true if there was not a CELEvalError. However, this makes it impossible for Protobuf messages to be handled properly.
The docstring describes the algorithm:
If e evaluates to a protocol buffers version 2 message and f is a defined field:
If f is a repeated field or map field, has(e.f) indicates whether the field is non-empty.
If f is a singular or oneof field, has(e.f) indicates whether the field is set.
If e evaluates to a protocol buffers version 3 message and f is a defined field:
If f is a repeated field or map field, has(e.f) indicates whether the field is non-empty.
If f is a oneof or singular message field, has(e.f) indicates whether the field is set.
If f is some other singular field, has(e.f) indicates whether the field's value is its default value (zero for numeric fields, false for booleans, empty for strings and bytes).
However, as far as I can tell, this is impossible to implement correctly no matter what. If you have a MessageType populated by omitting fields that are not present, you get incorrect behavior since unset fields are null instead of their default values. If you have a MessageType populated by setting default values, you get incorrect behavior because has returns true for fields that it shouldn't. What is needed is for has to return false while still populating the default value.
I don't currently have a minimal reproduction, in part because the library I am currently working on does not actually use the cel-python MessageType, but instead uses its own (though I did try to use cel-python MessageType and ran into basically the same issue, so I am pretty sure, as long as I am not missing anything, that it is similarly applicable.) That said, I hope this explanation is enough to either point me in the right direction: it seems like I am either misunderstanding how to use cel-python, or it is simply missing support for this. I think that there needs to be a way for has to be specialized for a given type; idiomatically it'd be best, in my opinion, if has could somehow call __contains__; then Python types, including MessageType, could just implement __contains__ and __getitem__ to do the right thing.
I would be willing to try to submit a PR to rectify this in the future if this sounds like a real issue and my solution would be OK, but I don't currently have a good enough understanding of how lark-parser works, so it may not be something I have time to approach for the moment.
- Lenguaje dominante
- Python
- Estrellas
- 174
- Forks
- 40
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de cloud-custodian/cel-python
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
cloud-custodian/cel-python#180 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
cloud-custodian/cel-python#194 ·
-
documentation enhancement tracking
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
cloud-custodian/cel-python#182 ·
-
Refresh Features Abiertodependencies
cloud-custodian/cel-python#172 · 2 comentarios · 1 asignado ·
-
enhancement
cloud-custodian/cel-python#169 · 3 comentarios · 1 asignado ·
Todos los issues de cloud-custodian/cel-python
Issues similares
-
agent-ready documentation needs-triage
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
-
documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
-
Add https://search.jeremyh.xyz/ Abiertoinstance instance add
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
searxng/searx-instances#939 · 1 comentario ·
-
area-deployment area-integrations triage:bot-seen
Dificultad 2/5 Medio día Aptitud para principiantes 86/100