2 from typing import Any, ByteString, Sequence, Tuple, Type, TypeVar, Union
4 from .descriptor import Descriptor, FieldDescriptor
5 from .internal.extension_dict import _ExtensionDict, _ExtensionFieldDescriptor
7 class Error(Exception): ...
8 class DecodeError(Error): ...
9 class EncodeError(Error): ...
11 _M = TypeVar("_M", bound=Message) # message type (of self)
13 if sys.version_info >= (3, 0):
14 _Serialized = ByteString
16 _Serialized = Union[bytes, buffer, unicode]
19 DESCRIPTOR: Descriptor
20 def __deepcopy__(self, memo=...): ...
21 def __eq__(self, other_msg): ...
22 def __ne__(self, other_msg): ...
23 def MergeFrom(self: _M, other_msg: _M) -> None: ...
24 def CopyFrom(self: _M, other_msg: _M) -> None: ...
25 def Clear(self) -> None: ...
26 def SetInParent(self) -> None: ...
27 def IsInitialized(self) -> bool: ...
28 def MergeFromString(self, serialized: _Serialized) -> int: ...
29 def ParseFromString(self, serialized: _Serialized) -> int: ...
30 def SerializeToString(self, deterministic: bool = ...) -> bytes: ...
31 def SerializePartialToString(self, deterministic: bool = ...) -> bytes: ...
32 def ListFields(self) -> Sequence[Tuple[FieldDescriptor, Any]]: ...
33 def HasExtension(self: _M, extension_handle: _ExtensionFieldDescriptor[_M, Any]) -> bool: ...
34 def ClearExtension(self: _M, extension_handle: _ExtensionFieldDescriptor[_M, Any]) -> None: ...
35 def ByteSize(self) -> int: ...
37 def FromString(cls: Type[_M], s: _Serialized) -> _M: ...
39 def Extensions(self: _M) -> _ExtensionDict[_M]: ...
40 # Intentionally left out typing on these three methods, because they are
41 # stringly typed and it is not useful to call them on a Message directly.
42 # We prefer more specific typing on individual subclasses of Message
43 # See https://github.com/dropbox/mypy-protobuf/issues/62 for details
44 def HasField(self, field_name: Any) -> bool: ...
45 def ClearField(self, field_name: Any) -> None: ...
46 def WhichOneof(self, oneof_group: Any) -> Any: ...
48 def __init__(self, **kwargs) -> None: ...