danielgtaylor / danielgtaylor/python-betterproto

[Enhancement] Add a Clear method to the Message class for compatibility.

Ouverte
#511 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
enhancement low priority
Langage dominant
Python
Étoiles
1.8k
Forks
234
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

When converting existing code to use this module over standard protobuf, one issue raised was the lack of `ParseFromString`. This has already been mentioned at #323, with a PR in the works at #336. However, this is blocked because it does not perform the same calls as the standard, namely, `Clear`. In my use of this module, i have worked around this issue by simply creating a new instance (which is always the default) instead of using an existing one, at which point just calling `parse` works fine.

Ideally, we'd need a `clear` function (preferably lowercase to match python syntax, but might want TitleCase for compatibility) on the abstract Message class and an implementation that resets all fields to their default values. We'd need to confirm that our implementation matches standard protobuf when it comes to user-defined default values.

to be clear, this isn't a bug, and it doesn't prevent the use of this module.
I'd look into addressing this myself but the logic used to set default values eludes me, at least at first glance.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Start with the abstract Message class and the existing parse and default-value logic; compare their behavior with standard protobuf, including user-defined defaults. Done means a clear method resets all fields to their default values and supports the compatibility work described in #323 and #336.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
backend-api-design
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.