From c67c4f95ffa18f9cf9e513263fbf9e1c69c1ad8a Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Tue, 13 Jul 2021 21:41:08 -0500 Subject: [PATCH] Support arbitrary values for extension values 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. --- stubs/protobuf/google/protobuf/internal/extension_dict.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/protobuf/google/protobuf/internal/extension_dict.pyi b/stubs/protobuf/google/protobuf/internal/extension_dict.pyi index 765a28a332cf..e2d41e82346d 100644 --- a/stubs/protobuf/google/protobuf/internal/extension_dict.pyi +++ b/stubs/protobuf/google/protobuf/internal/extension_dict.pyi @@ -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]): ...