99from google .protobuf import any_pb2 , wrappers_pb2
1010from google .protobuf .message import Message
1111
12- TPythonType = TypeVar ("TPythonType " , covariant = True )
13- TProtobufType = TypeVar ("TProtobufType " , bound = Message , covariant = True )
12+ TPythonType_co = TypeVar ("TPythonType_co " , covariant = True )
13+ TProtobufType_co = TypeVar ("TProtobufType_co " , bound = Message , covariant = True )
1414
1515_logger = logging .getLogger (__name__ )
1616
1717
18- class Converter (Generic [TPythonType , TProtobufType ], ABC ):
18+ class Converter (Generic [TPythonType_co , TProtobufType_co ], ABC ):
1919 """A class that defines how to convert between Python objects and protobuf Any messages."""
2020
2121 @property
2222 @abstractmethod
23- def python_type (self ) -> Type [TPythonType ]:
23+ def python_type (self ) -> Type [TPythonType_co ]:
2424 """The Python type that this converter handles."""
2525
2626 @property
2727 @abstractmethod
28- def protobuf_message (self ) -> Type [TProtobufType ]:
28+ def protobuf_message (self ) -> Type [TProtobufType_co ]:
2929 """The type-specific protobuf message for the Python type."""
3030
3131 @property
@@ -35,10 +35,10 @@ def protobuf_typename(self) -> str:
3535
3636 @abstractmethod
3737 def to_protobuf (self , python_value : Any ) -> any_pb2 .Any :
38- """Convert the Python object to its type-specific protobuf message and pack it into an any_pb2.Any."""
38+ """Convert the Python object to its type-specific message and pack it as any_pb2.Any."""
3939
4040 @abstractmethod
41- def to_python (self , protobuf_value : any_pb2 .Any ) -> TPythonType :
41+ def to_python (self , protobuf_value : any_pb2 .Any ) -> TPythonType_co :
4242 """Convert the protobuf message to its matching Python type."""
4343
4444
0 commit comments