mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-24 04:41:30 +08:00
Make EnumTypeWrapper generic in google.protobuf.internal (#3995)
This is necessary so that mypy-protobuf can autogenerate NewType wrappers around the int values of the enum!
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
from typing import Any, List, Tuple
|
||||
from typing import Any, Generic, List, Tuple, TypeVar
|
||||
|
||||
class EnumTypeWrapper(object):
|
||||
def __init__(self, enum_type: Any) -> None: ...
|
||||
def Name(self, number: int) -> bytes: ...
|
||||
def Value(self, name: bytes) -> int: ...
|
||||
def keys(self) -> List[bytes]: ...
|
||||
def values(self) -> List[int]: ...
|
||||
@classmethod
|
||||
def items(cls) -> List[Tuple[bytes, int]]: ...
|
||||
from google.protobuf.descriptor import EnumDescriptor
|
||||
|
||||
_V = TypeVar("_V", bound=int)
|
||||
|
||||
# Expose a generic version so that those using mypy-protobuf
|
||||
# can get autogenerated NewType wrapper around the int values
|
||||
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 keys(self) -> List[str]: ...
|
||||
def values(self) -> List[_V]: ...
|
||||
def items(self) -> List[Tuple[str, _V]]: ...
|
||||
|
||||
class EnumTypeWrapper(_EnumTypeWrapper[int]): ...
|
||||
|
||||
Reference in New Issue
Block a user