protobuf
protobuf copied to clipboard
EnumTypeWrapper objects should be usable according to the enum.Enum interface (or maybe the enum.IntEnum interface)
To what language does this apply? Python.
Describe the problem you are trying to solve.
The Python language (since 3.4) has an enum
module, but the generated Python classes in _pb2
files don't behave according to the interfaces of the classes defined in the enum
module.
Describe the solution you'd like
I think EnumTypeWrapper
objects should support being used, as much as possible, as though they were subclasses of enum.Enum
.
Describe alternatives you've considered
enum.IntEnum
, though disfavored in new code, exists to allow int
-based ad hoc "enums" from before Python 3.4 to be upgraded to be usable according to the interface of enum.Enum
. It may have a role to play.
Additional context
This would be really great for type-checking; it would allow authors to describe parameters and return values as of type my_module_pb2.MyEnum
rather than as of type int
.
See https://github.com/protocolbuffers/protobuf/pull/5234, where I asked whether the EnumTypeWrapper classes can be replaced by enum from the stdlib.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive
because the last activity was over 90 days ago.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive because the last activity was over 90 days ago.
Yes, this issue still tracks a fantastic opportunity for improvement in Protocol Buffers Python.
I would like to take this on if it's still unassigned.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive
because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.
Still a valid, not-yet-implemented improvement suggestion, Mr. Robot.