danielgtaylor / danielgtaylor/python-betterproto
proper support of __get_pydantic_core_schema__
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 234
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### Summary
I'd like to dynamically add non-public methods to my Enums
### What is the feature request for?
The core library
### The Problem
I'm mixing up betterproto.Enum with pydantic classes for easier conversion between my database objects and protobuf messages. To use pydantic, I have to add validator based on [this instruction](https://docs.pydantic.dev/2.0/usage/types/custom/#handling-third-party-types). Thus, I decided to dynamically add a class method to a generated betterproto.Enum. However, betterproto.enum does not allow it by [this](https://github.com/danielgtaylor/python-betterproto/blob/master/src/betterproto/enum.py#L109)
Are there any other parts of the code affected by adding a custom function `__get_pydantic_core_schema__` to my generated Enum?
### The Ideal Solution
I'd like `__set_attr__` to accept new attributes if the new attributes are private (i.e.,starting with `__`) I can contribute if this direction is acceptable.
### The Current Solution
If no other solutions, I will fork this repo and just remove the constraint. I don't like to fork for a hack.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da src/betterproto/enum.py, in prossimità della restrizione degli attributi collegati, e verifica come le classi Enum generate gestiscono __setattr__. Confronta questo comportamento con le indicazioni sui tipi personalizzati di Pydantic collegate nell’issue, quindi verifica se consentire __get_pydantic_core_schema__ influisce su altri percorsi Enum. Il lavoro è completato quando i metodi di integrazione privati funzionano senza consentire attributi pubblici non correlati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100