|
1 |
| -from typing import Any, List, Tuple |
2 |
| - |
3 |
| -class EnumTypeWrapper(object): |
4 |
| - def __init__(self, enum_type: Any) -> None: ... |
5 |
| - def Name(self, number: int) -> bytes: ... |
6 |
| - def Value(self, name: bytes) -> int: ... |
7 |
| - def keys(self) -> List[bytes]: ... |
8 |
| - def values(self) -> List[int]: ... |
9 |
| - @classmethod |
10 |
| - def items(cls) -> List[Tuple[bytes, int]]: ... |
| 1 | +from typing import Any, Generic, List, Tuple, TypeVar |
| 2 | + |
| 3 | +from google.protobuf.descriptor import EnumDescriptor |
| 4 | + |
| 5 | +_V = TypeVar("_V", bound=int) |
| 6 | + |
| 7 | +# Expose a generic version so that those using mypy-protobuf |
| 8 | +# can get autogenerated NewType wrapper around the int values |
| 9 | +class _EnumTypeWrapper(Generic[_V]): |
| 10 | + DESCRIPTOR: EnumDescriptor |
| 11 | + |
| 12 | + def __init__(self, enum_type: EnumDescriptor) -> None: ... |
| 13 | + def Name(self, number: _V) -> str: ... |
| 14 | + def Value(self, name: str) -> _V: ... |
| 15 | + def keys(self) -> List[str]: ... |
| 16 | + def values(self) -> List[_V]: ... |
| 17 | + def items(self) -> List[Tuple[str, _V]]: ... |
| 18 | + |
| 19 | +class EnumTypeWrapper(_EnumTypeWrapper[int]): ... |
0 commit comments