Skip to content

proper support of __get_pydantic_core_schema__ #646

Open
@jbkoh

Description

@jbkoh

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. Thus, I decided to dynamically add a class method to a generated betterproto.Enum. However, betterproto.enum does not allow it by this

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions