Skip to content

Commit 342a830

Browse files
committed
converters: Fix incompatible method overrides
c:\Dev\nipanel-python\src\nipanel\converters\builtin.py c:\Dev\nipanel-python\src\nipanel\converters\builtin.py:29:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride) c:\Dev\nipanel-python\src\nipanel\converters\builtin.py:51:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride) c:\Dev\nipanel-python\src\nipanel\converters\builtin.py:73:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride) c:\Dev\nipanel-python\src\nipanel\converters\builtin.py:95:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride) c:\Dev\nipanel-python\src\nipanel\converters\builtin.py:117:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride) c:\Dev\nipanel-python\src\nipanel\converters\builtin.py:141:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride) c:\Dev\nipanel-python\src\nipanel\converters\builtin.py:169:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride) c:\Dev\nipanel-python\src\nipanel\converters\builtin.py:197:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride) c:\Dev\nipanel-python\src\nipanel\converters\builtin.py:223:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride) c:\Dev\nipanel-python\src\nipanel\converters\builtin.py:249:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride) c:\Dev\nipanel-python\src\nipanel\converters\protobuf_types.py c:\Dev\nipanel-python\src\nipanel\converters\protobuf_types.py:45:9 - error: Method "to_python_value" overrides class "Converter" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "protobuf_message", override parameter is named "protobuf_value" (reportIncompatibleMethodOverride)
1 parent a4a2924 commit 342a830

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/nipanel/converters/builtin.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from typing import Type
55

66
from google.protobuf import wrappers_pb2
7-
from ni.pythonpanel.v1 import python_panel_types_pb2
87

8+
from ni.pythonpanel.v1 import python_panel_types_pb2
99
from nipanel.converters import Converter
1010

1111

@@ -26,9 +26,9 @@ def to_protobuf_message(self, python_value: bool) -> wrappers_pb2.BoolValue:
2626
"""Convert the Python bool to a protobuf wrappers_pb2.BoolValue."""
2727
return self.protobuf_message(value=python_value)
2828

29-
def to_python_value(self, protobuf_value: wrappers_pb2.BoolValue) -> bool:
29+
def to_python_value(self, protobuf_message: wrappers_pb2.BoolValue) -> bool:
3030
"""Convert the protobuf message to a Python bool."""
31-
return protobuf_value.value
31+
return protobuf_message.value
3232

3333

3434
class BytesConverter(Converter[bytes, wrappers_pb2.BytesValue]):
@@ -48,9 +48,9 @@ def to_protobuf_message(self, python_value: bytes) -> wrappers_pb2.BytesValue:
4848
"""Convert the Python bytes string to a protobuf wrappers_pb2.BytesValue."""
4949
return self.protobuf_message(value=python_value)
5050

51-
def to_python_value(self, protobuf_value: wrappers_pb2.BytesValue) -> bytes:
51+
def to_python_value(self, protobuf_message: wrappers_pb2.BytesValue) -> bytes:
5252
"""Convert the protobuf message to a Python bytes string."""
53-
return protobuf_value.value
53+
return protobuf_message.value
5454

5555

5656
class FloatConverter(Converter[float, wrappers_pb2.DoubleValue]):
@@ -70,9 +70,9 @@ def to_protobuf_message(self, python_value: float) -> wrappers_pb2.DoubleValue:
7070
"""Convert the Python float to a protobuf wrappers_pb2.DoubleValue."""
7171
return self.protobuf_message(value=python_value)
7272

73-
def to_python_value(self, protobuf_value: wrappers_pb2.DoubleValue) -> float:
73+
def to_python_value(self, protobuf_message: wrappers_pb2.DoubleValue) -> float:
7474
"""Convert the protobuf message to a Python float."""
75-
return protobuf_value.value
75+
return protobuf_message.value
7676

7777

7878
class IntConverter(Converter[int, wrappers_pb2.Int64Value]):
@@ -92,9 +92,9 @@ def to_protobuf_message(self, python_value: int) -> wrappers_pb2.Int64Value:
9292
"""Convert the Python int to a protobuf wrappers_pb2.Int64Value."""
9393
return self.protobuf_message(value=python_value)
9494

95-
def to_python_value(self, protobuf_value: wrappers_pb2.Int64Value) -> int:
95+
def to_python_value(self, protobuf_message: wrappers_pb2.Int64Value) -> int:
9696
"""Convert the protobuf message to a Python int."""
97-
return protobuf_value.value
97+
return protobuf_message.value
9898

9999

100100
class StrConverter(Converter[str, wrappers_pb2.StringValue]):
@@ -114,9 +114,9 @@ def to_protobuf_message(self, python_value: str) -> wrappers_pb2.StringValue:
114114
"""Convert the Python str to a protobuf wrappers_pb2.StringValue."""
115115
return self.protobuf_message(value=python_value)
116116

117-
def to_python_value(self, protobuf_value: wrappers_pb2.StringValue) -> str:
117+
def to_python_value(self, protobuf_message: wrappers_pb2.StringValue) -> str:
118118
"""Convert the protobuf message to a Python string."""
119-
return protobuf_value.value
119+
return protobuf_message.value
120120

121121

122122
class BoolCollectionConverter(Converter[Collection[bool], python_panel_types_pb2.BoolCollection]):
@@ -139,10 +139,10 @@ def to_protobuf_message(
139139
return self.protobuf_message(values=python_value)
140140

141141
def to_python_value(
142-
self, protobuf_value: python_panel_types_pb2.BoolCollection
142+
self, protobuf_message: python_panel_types_pb2.BoolCollection
143143
) -> Collection[bool]:
144144
"""Convert the protobuf message to a Python collection of bools."""
145-
return list(protobuf_value.values)
145+
return list(protobuf_message.values)
146146

147147

148148
class BytesCollectionConverter(
@@ -167,10 +167,10 @@ def to_protobuf_message(
167167
return self.protobuf_message(values=python_value)
168168

169169
def to_python_value(
170-
self, protobuf_value: python_panel_types_pb2.ByteStringCollection
170+
self, protobuf_message: python_panel_types_pb2.ByteStringCollection
171171
) -> Collection[bytes]:
172172
"""Convert the protobuf message to a Python collection of byte strings."""
173-
return list(protobuf_value.values)
173+
return list(protobuf_message.values)
174174

175175

176176
class FloatCollectionConverter(
@@ -195,10 +195,10 @@ def to_protobuf_message(
195195
return self.protobuf_message(values=python_value)
196196

197197
def to_python_value(
198-
self, protobuf_value: python_panel_types_pb2.FloatCollection
198+
self, protobuf_message: python_panel_types_pb2.FloatCollection
199199
) -> Collection[float]:
200200
"""Convert the protobuf message to a Python collection of floats."""
201-
return list(protobuf_value.values)
201+
return list(protobuf_message.values)
202202

203203

204204
class IntCollectionConverter(Converter[Collection[int], python_panel_types_pb2.IntCollection]):
@@ -221,10 +221,10 @@ def to_protobuf_message(
221221
return self.protobuf_message(values=python_value)
222222

223223
def to_python_value(
224-
self, protobuf_value: python_panel_types_pb2.IntCollection
224+
self, protobuf_message: python_panel_types_pb2.IntCollection
225225
) -> Collection[int]:
226226
"""Convert the protobuf message to a Python collection of integers."""
227-
return list(protobuf_value.values)
227+
return list(protobuf_message.values)
228228

229229

230230
class StrCollectionConverter(Converter[Collection[str], python_panel_types_pb2.StringCollection]):
@@ -247,7 +247,7 @@ def to_protobuf_message(
247247
return self.protobuf_message(values=python_value)
248248

249249
def to_python_value(
250-
self, protobuf_value: python_panel_types_pb2.StringCollection
250+
self, protobuf_message: python_panel_types_pb2.StringCollection
251251
) -> Collection[str]:
252252
"""Convert the protobuf message to a Python collection of strings."""
253-
return list(protobuf_value.values)
253+
return list(protobuf_message.values)

src/nipanel/converters/protobuf_types.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from typing import Type, Union
44

5-
from ni.protobuf.types import scalar_pb2
65
from nitypes.scalar import Scalar
76
from typing_extensions import TypeAlias
87

8+
from ni.protobuf.types import scalar_pb2
99
from nipanel.converters import Converter
1010

1111
_AnyScalarType: TypeAlias = Union[bool, int, float, str]
@@ -42,14 +42,14 @@ def to_protobuf_message(self, python_value: Scalar[_AnyScalarType]) -> scalar_pb
4242

4343
return message
4444

45-
def to_python_value(self, protobuf_value: scalar_pb2.ScalarData) -> Scalar[_AnyScalarType]:
45+
def to_python_value(self, protobuf_message: scalar_pb2.ScalarData) -> Scalar[_AnyScalarType]:
4646
"""Convert the protobuf message to a Python Scalar."""
47-
if protobuf_value.units is None:
47+
if protobuf_message.units is None:
4848
raise ValueError("protobuf.units cannot be None.")
4949

50-
pb_type = str(protobuf_value.WhichOneof("value"))
50+
pb_type = str(protobuf_message.WhichOneof("value"))
5151
if pb_type not in _SCALAR_TYPE_TO_PB_ATTR_MAP.values():
5252
raise ValueError(f"Unexpected value for protobuf_value.WhichOneOf: {pb_type}")
5353

54-
value = getattr(protobuf_value, pb_type)
55-
return Scalar(value, protobuf_value.units)
54+
value = getattr(protobuf_message, pb_type)
55+
return Scalar(value, protobuf_message.units)

0 commit comments

Comments
 (0)