Open sfc-gh-smao opened 1 month ago
I guess the doc is wrong, should be:
value_a = myproto_pb2.SomeEnum.values_by_name['VALUE_A'] or myproto_pb2.VALUE_A or myproto_pb2.SomeEnum.Value('VALUE_A')
value_a = myproto_pb2.SomeEnum.VALUE_A
actually works. It's just that mypy gave an error on it.
What version of protobuf and what language are you using? Protobuf 4.24.0
Language: Python
What operating system (Linux, Windows, ...) and version? macOS 14.5
What runtime / compiler are you using (e.g., python version or gcc version) Python 3.8
What did you do? I created the following proto
What did you expect to see
According to https://protobuf.dev/reference/python/python-generated/#enum, I expect I can access the enum value via any of the following ways:
What did you see instead?
When accessing
myproto_pb2.SomeEnum.VALUE_A
, I got the following error from mypy (version1.11.0
):Is this a known issue? I'm not sure if this is an issue with protobuf, protoc, or mypy.