Implementation of `has` macro is incomplete
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
Piste de recherche
Commencez par l’implémentation de has dans src/celpy/evaluation.py, autour de la ligne 1273, puis suivez la manière dont MessageType représente les champs protobuf omis et ceux auxquels une valeur par défaut est attribuée. Reproduisez le comportement signalé avec un exemple protobuf minimal avant de choisir une approche ; le travail est considéré comme terminé lorsque has suit les règles de présence documentées de proto2 et proto3 sans confondre les valeurs par défaut avec les champs définis.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 173
- Forks
- 41
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Aucun modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de cloud-custodian/cel-python
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
cloud-custodian/cel-python#180 · 1 commentaire ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
cloud-custodian/cel-python#194 ·
-
documentation enhancement tracking
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
cloud-custodian/cel-python#182 ·
-
Refresh FeaturesPeut-être à nouveau libre @slott56 l’a pris il y a 147 jours, et aucune pull request n’est ouverte. Ouvertedependencies
cloud-custodian/cel-python#172 · 2 commentaires · 1 personne assignée ·
-
Permit multiple threads to share a common EnvironmentPeut-être à nouveau libre @Quantum0uasar l’a pris il y a 135 jours, et aucune pull request n’est ouverte. Ouverteenhancement
cloud-custodian/cel-python#169 · 3 commentaires · 1 personne assignée ·
Toutes les issues de cloud-custodian/cel-python
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Deltares/imod-python#1940 ·
Les mainteneurs répondent en général sous 1 jour
-
effort: low prio: low ready
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
digitalfabrik/integreat-cms#4621 ·
Les mainteneurs répondent en général sous 5 jours
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
ioos/compliance-checker#1375 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
netbox status: backlog topic: testing type: housekeeping
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
netbox-community/netbox#23395 ·
Les mainteneurs répondent en général sous 1 jour