Genericize types for stringly typed methods on google.protobuf.Message (#2807)

This commit is contained in:
Nipunn Koorapati
2019-02-22 22:23:32 -08:00
committed by Jelle Zijlstra
parent 3f83195558
commit 07ea6614c8

View File

@@ -1,4 +1,4 @@
from typing import Any, Sequence, Optional, Text, Tuple
from typing import Any, Sequence, Optional, Tuple
from .descriptor import (
DescriptorBase,
@@ -28,14 +28,19 @@ class Message:
def SerializeToString(self, deterministic: bool = ...) -> bytes: ...
def SerializePartialToString(self, deterministic: bool = ...) -> bytes: ...
def ListFields(self) -> Sequence[Tuple[FieldDescriptor, Any]]: ...
def HasField(self, field_name: Text) -> bool: ...
def ClearField(self, field_name: Text) -> None: ...
def WhichOneof(self, oneof_group) -> Optional[Text]: ...
def HasExtension(self, extension_handle): ...
def ClearExtension(self, extension_handle): ...
def ByteSize(self) -> int: ...
@property
def Extensions(self) -> _ExtensionDict: ...
# Intentionally left out typing on these three methods, because they are
# stringly typed and it is not useful to call them on a Message directly.
# We prefer more specific typing on individual subclasses of Message
# See https://github.com/dropbox/mypy-protobuf/issues/62 for details
def HasField(self, field_name: Any) -> bool: ...
def ClearField(self, field_name: Any) -> None: ...
def WhichOneof(self, oneof_group: Any) -> Any: ...
# TODO: check kwargs
def __init__(self, **kwargs) -> None: ...