Support arbitrary values for extension values (#5774)

Proto itself supports primitives, not just messages.
See https://github.com/dropbox/mypy-protobuf/issues/244 for an example
motivating this change.

Test Plan: I was able to use MYPYPATH to test an updated version of
mypy-protobuf with this change.
This commit is contained in:
Nipunn Koorapati
2021-07-13 21:13:45 -07:00
committed by GitHub
parent 0cd4ee39a2
commit 4765978f6c

View File

@@ -1,10 +1,10 @@
from typing import Any, Generic, Iterator, TypeVar
from typing import Any, Generic, Iterator, Text, TypeVar, Union
from google.protobuf.descriptor import FieldDescriptor
from google.protobuf.message import Message
_ContainerMessageT = TypeVar("_ContainerMessageT", bound=Message)
_ExtenderMessageT = TypeVar("_ExtenderMessageT", bound=Message)
_ExtenderMessageT = TypeVar("_ExtenderMessageT", bound=Union[Message, bool, int, float, Text, bytes])
class _ExtensionFieldDescriptor(FieldDescriptor, Generic[_ContainerMessageT, _ExtenderMessageT]): ...