1- import sys
21from enum import EnumMeta , IntEnum
32
43from typing_extensions import Self
54
65
76class _EnumMeta (EnumMeta ):
87 def __new__ (metacls , cls , bases , classdict ):
9- # Find the proto names if defined
10- if sys .version_info >= (3 , 11 ):
11- proto_names = classdict .pop ("betterproto_proto_names" , {})
12- classdict ._member_names .pop ("betterproto_proto_names" , None )
13- else :
14- proto_names = {}
15- if "betterproto_proto_names" in classdict :
16- proto_names = classdict .pop ("betterproto_proto_names" )
17- classdict ._member_names .remove ("betterproto_proto_names" )
18-
198 enum_class = super ().__new__ (metacls , cls , bases , classdict )
9+ proto_names = enum_class .betterproto_value_to_renamed_proto_names () # type: ignore[reportAttributeAccessIssue]
2010
2111 # Attach extra info to each enum member
2212 for member in enum_class :
@@ -32,6 +22,14 @@ class Enum(IntEnum, metaclass=_EnumMeta):
3222 def proto_name (self ) -> str | None :
3323 return self ._proto_name # type: ignore[reportAttributeAccessIssue]
3424
25+ @classmethod
26+ def betterproto_value_to_renamed_proto_names (cls ) -> dict [int , str ]:
27+ return {}
28+
29+ @classmethod
30+ def betterproto_renamed_proto_names_to_value (cls ) -> dict [str , int ]:
31+ return {}
32+
3533 @classmethod
3634 def _missing_ (cls , value ):
3735 # If the given value is not an integer, let the standard enum implementation raise an error
0 commit comments