Skip to content

Commit 83e6363

Browse files
committed
converters: Use type variables more consistently
Signed-off-by: Brad Keryan <brad.keryan@ni.com>
1 parent 072a3ac commit 83e6363

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/nipanel/_converters.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ def protobuf_typename(self) -> str:
3333
"""The protobuf name for the type."""
3434
return self.protobuf_message.DESCRIPTOR.full_name # type: ignore[no-any-return]
3535

36-
def to_protobuf_any(self, python_value: Any) -> any_pb2.Any:
36+
def to_protobuf_any(self, python_value: _TPythonType) -> any_pb2.Any:
3737
"""Convert the Python object to its type-specific message and pack it as any_pb2.Any."""
3838
message = self.to_protobuf_message(python_value)
3939
as_any = any_pb2.Any()
4040
as_any.Pack(message)
4141
return as_any
4242

4343
@abstractmethod
44-
def to_protobuf_message(self, python_value: Any) -> Message:
44+
def to_protobuf_message(self, python_value: _TPythonType) -> _TProtobufType:
4545
"""Convert the Python object to its type-specific message."""
4646

4747
def to_python(self, protobuf_value: any_pb2.Any) -> _TPythonType:
@@ -70,7 +70,7 @@ def protobuf_message(self) -> Type[wrappers_pb2.BoolValue]:
7070
"""The type-specific protobuf message for the Python type."""
7171
return wrappers_pb2.BoolValue
7272

73-
def to_protobuf_message(self, python_value: bool) -> Message:
73+
def to_protobuf_message(self, python_value: bool) -> wrappers_pb2.BoolValue:
7474
"""Convert the Python bool to a protobuf wrappers_pb2.BoolValue."""
7575
return self.protobuf_message(value=python_value)
7676

@@ -92,7 +92,7 @@ def protobuf_message(self) -> Type[wrappers_pb2.BytesValue]:
9292
"""The type-specific protobuf message for the Python type."""
9393
return wrappers_pb2.BytesValue
9494

95-
def to_protobuf_message(self, python_value: bytes) -> Message:
95+
def to_protobuf_message(self, python_value: bytes) -> wrappers_pb2.BytesValue:
9696
"""Convert the Python bytes string to a protobuf wrappers_pb2.BytesValue."""
9797
return self.protobuf_message(value=python_value)
9898

@@ -114,7 +114,7 @@ def protobuf_message(self) -> Type[wrappers_pb2.DoubleValue]:
114114
"""The type-specific protobuf message for the Python type."""
115115
return wrappers_pb2.DoubleValue
116116

117-
def to_protobuf_message(self, python_value: float) -> Message:
117+
def to_protobuf_message(self, python_value: float) -> wrappers_pb2.DoubleValue:
118118
"""Convert the Python float to a protobuf wrappers_pb2.DoubleValue."""
119119
return self.protobuf_message(value=python_value)
120120

@@ -136,7 +136,7 @@ def protobuf_message(self) -> Type[wrappers_pb2.Int64Value]:
136136
"""The type-specific protobuf message for the Python type."""
137137
return wrappers_pb2.Int64Value
138138

139-
def to_protobuf_message(self, python_value: int) -> Message:
139+
def to_protobuf_message(self, python_value: int) -> wrappers_pb2.Int64Value:
140140
"""Convert the Python int to a protobuf wrappers_pb2.Int64Value."""
141141
return self.protobuf_message(value=python_value)
142142

@@ -158,7 +158,7 @@ def protobuf_message(self) -> Type[wrappers_pb2.StringValue]:
158158
"""The type-specific protobuf message for the Python type."""
159159
return wrappers_pb2.StringValue
160160

161-
def to_protobuf_message(self, python_value: str) -> Message:
161+
def to_protobuf_message(self, python_value: str) -> wrappers_pb2.StringValue:
162162
"""Convert the Python str to a protobuf wrappers_pb2.StringValue."""
163163
return self.protobuf_message(value=python_value)
164164

0 commit comments

Comments
 (0)