diff --git a/third_party/2and3/google/protobuf/message.pyi b/third_party/2and3/google/protobuf/message.pyi index 3fc8c33d2..0b3e15258 100644 --- a/third_party/2and3/google/protobuf/message.pyi +++ b/third_party/2and3/google/protobuf/message.pyi @@ -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: ...