From a3b3f6845b3271a73be6b50df1ca972132ad1386 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Thu, 4 Feb 2021 15:03:37 +0000 Subject: [PATCH] Allow unicode and bytes in the EnumTypeWrapper.Value classmethod (#5004) Here is a unit test which shows that this behavior is accepted by protobuf itself at runtime in both py2 and py3 https://github.com/dropbox/mypy-protobuf/pull/205 --- stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi b/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi index bb983403c..079fca6a3 100644 --- a/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi +++ b/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi @@ -1,4 +1,4 @@ -from typing import Generic, List, Tuple, TypeVar +from typing import Generic, List, Tuple, TypeVar, Union from google.protobuf.descriptor import EnumDescriptor @@ -10,7 +10,7 @@ class _EnumTypeWrapper(Generic[_V]): DESCRIPTOR: EnumDescriptor def __init__(self, enum_type: EnumDescriptor) -> None: ... def Name(self, number: _V) -> str: ... - def Value(self, name: str) -> _V: ... + def Value(self, name: Union[str, bytes]) -> _V: ... def keys(self) -> List[str]: ... def values(self) -> List[_V]: ... def items(self) -> List[Tuple[str, _V]]: ...