@@ -2,7 +2,7 @@ import sys
2
2
3
3
from typing import Any , Sequence , Optional , Tuple , Type , TypeVar , Union
4
4
5
- from .descriptor import DescriptorBase , FieldDescriptor
5
+ from .descriptor import Descriptor , DescriptorBase , FieldDescriptor
6
6
7
7
class Error (Exception ): ...
8
8
class DecodeError (Error ): ...
@@ -12,20 +12,20 @@ class _ExtensionDict:
12
12
def __getitem__ (self , extension_handle : DescriptorBase ) -> Any : ...
13
13
def __setitem__ (self , extension_handle : DescriptorBase , value : Any ) -> None : ...
14
14
15
- _T = TypeVar ("_T" )
15
+ _M = TypeVar ("_M" , bound = Message ) # message type (of self )
16
16
17
17
if sys .version_info < (3 ,):
18
18
_Serialized = Union [bytes , buffer , unicode ]
19
19
else :
20
20
_Serialized = bytes
21
21
22
22
class Message :
23
- DESCRIPTOR : Any
23
+ DESCRIPTOR : Descriptor
24
24
def __deepcopy__ (self , memo = ...): ...
25
25
def __eq__ (self , other_msg ): ...
26
26
def __ne__ (self , other_msg ): ...
27
- def MergeFrom (self , other_msg : Message ) -> None : ...
28
- def CopyFrom (self , other_msg : Message ) -> None : ...
27
+ def MergeFrom (self : _M , other_msg : _M ) -> None : ...
28
+ def CopyFrom (self : _M , other_msg : _M ) -> None : ...
29
29
def Clear (self ) -> None : ...
30
30
def SetInParent (self ) -> None : ...
31
31
def IsInitialized (self ) -> bool : ...
@@ -38,9 +38,10 @@ class Message:
38
38
def ClearExtension (self , extension_handle ): ...
39
39
def ByteSize (self ) -> int : ...
40
40
@classmethod
41
- def FromString (cls : Type [_T ], s : _Serialized ) -> _T : ...
41
+ def FromString (cls : Type [_M ], s : _Serialized ) -> _M : ...
42
42
@property
43
43
def Extensions (self ) -> _ExtensionDict : ...
44
+
44
45
# Intentionally left out typing on these three methods, because they are
45
46
# stringly typed and it is not useful to call them on a Message directly.
46
47
# We prefer more specific typing on individual subclasses of Message
0 commit comments