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
This commit is contained in:
Nipunn Koorapati
2021-02-04 15:03:37 +00:00
committed by GitHub
parent a00a8de1f1
commit a3b3f6845b

View File

@@ -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]]: ...