danielgtaylor / danielgtaylor/python-betterproto
proper support of __get_pydantic_core_schema__
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
### 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.
Contributor guide
Assessment
This issue has not been assessed yet.