Provide a way to use a custom base class instead of betterproto.Message
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia con la progettazione dell’argomento della CLI del compilatore e del template Jinja init menzionato nell’issue, quindi esamina come le classi dei messaggi generate scelgono betterproto.Message e come vengono scritti i file init.py generati. Il lavoro è completato quando per i messaggi generati viene utilizzata una classe base personalizzata configurata e i sottopackage possono essere importati tramite la struttura dei package generata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Allow to customize the base class, to provide helper methods and enrich the model
What is the feature request for?
The core library
The Problem
We developed an internal library on top of betterproto and pika rabbitmq packages.
During development, we found that
- betterproto lacks a way to customize the base class for the generated messages classes.
- it's not possible to access message classes in the following way:
import mylib as ml
ml.messages.device.settings.ConfigureDevice(*args)
The Ideal Solution
To ease all above, would be handy to provide:
- A way to use a
MyMessageBaseClass(betterproto.Message)as base class for generated messages. This would probably be a new cli argument for the compiler e.g.--base_class=mylib.base.MyMessageBaseClassto use in the init jinja template. - import subpackages (if any) in the
__init__.pygenerated files.
The Current Solution
To enrich the classes with helper methods and to override some methods of the betterproto.Message class, we first patched the generated classes, to add mixins and overridden methods at runtime.
This is working well, but Python IDEs' support is limited.
We solved some of the issues above by adding a post compilation step at installation time, to add code to the betterproto generated files.
During this step, we also add subpackages imports to __init__.py files, to access messages conveniently using the fqn (see point 2. of the issue).
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 235
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di danielgtaylor/python-betterproto
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
-
bug investigation needed
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
-
bug investigation needed
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
bug investigation needed
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
danielgtaylor/python-betterproto#676 · 3 commenti ·
Tutte le issue di danielgtaylor/python-betterproto
Issue simili
-
[Bug] Unit tests reach real Bedrock call paths without patching the modelForse già presa @proton0210 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
aws-samples/sample-aws-genai-db-modernizer#1318 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
pyarrow-25.0.1-cp310-cp310-manylinux_2_28_x86_64.whl: 1 vulnerabilities (highest severity is: 5.3)ApertaMend: dependency security vulnerability
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
capitalone/locopy#394 ·
-
[Bug] Unhandled ValueError terminates watchdog thread when GISRC value contains multiple colonsApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
sdk-typescript: unquoted COPY globs in shell form are silently dropped from the image build contextApertabug javascript
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
ietf-tools/datatracker#11922 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno