77from google .protobuf import duration_pb2 , timestamp_pb2 , wrappers_pb2
88from ni .panels .v1 import panel_types_pb2
99
10- from nipanel .converters import Converter
10+ from nipanel .converters import Converter , CollectionConverter
1111
1212
1313class BoolConverter (Converter [bool , wrappers_pb2 .BoolValue ]):
1414 """A converter for boolean types."""
1515
1616 @property
17- def python_typename (self ) -> str :
17+ def python_type (self ) -> type :
1818 """The Python type that this converter handles."""
19- return f" { bool . __module__ } . { bool . __name__ } "
19+ return bool
2020
2121 @property
2222 def protobuf_message (self ) -> Type [wrappers_pb2 .BoolValue ]:
@@ -36,9 +36,9 @@ class BytesConverter(Converter[bytes, wrappers_pb2.BytesValue]):
3636 """A converter for byte string types."""
3737
3838 @property
39- def python_typename (self ) -> str :
39+ def python_type (self ) -> type :
4040 """The Python type that this converter handles."""
41- return f" { bytes . __module__ } . { bytes . __name__ } "
41+ return bytes
4242
4343 @property
4444 def protobuf_message (self ) -> Type [wrappers_pb2 .BytesValue ]:
@@ -58,9 +58,9 @@ class FloatConverter(Converter[float, wrappers_pb2.DoubleValue]):
5858 """A converter for floating point types."""
5959
6060 @property
61- def python_typename (self ) -> str :
61+ def python_type (self ) -> type :
6262 """The Python type that this converter handles."""
63- return f" { float . __module__ } . { float . __name__ } "
63+ return float
6464
6565 @property
6666 def protobuf_message (self ) -> Type [wrappers_pb2 .DoubleValue ]:
@@ -80,9 +80,9 @@ class IntConverter(Converter[int, wrappers_pb2.Int64Value]):
8080 """A converter for integer types."""
8181
8282 @property
83- def python_typename (self ) -> str :
83+ def python_type (self ) -> type :
8484 """The Python type that this converter handles."""
85- return f" { int . __module__ } . { int . __name__ } "
85+ return int
8686
8787 @property
8888 def protobuf_message (self ) -> Type [wrappers_pb2 .Int64Value ]:
@@ -102,9 +102,9 @@ class StrConverter(Converter[str, wrappers_pb2.StringValue]):
102102 """A converter for text string types."""
103103
104104 @property
105- def python_typename (self ) -> str :
105+ def python_type (self ) -> type :
106106 """The Python type that this converter handles."""
107- return f" { str . __module__ } . { str . __name__ } "
107+ return str
108108
109109 @property
110110 def protobuf_message (self ) -> Type [wrappers_pb2 .StringValue ]:
@@ -124,9 +124,9 @@ class DTDateTimeConverter(Converter[dt.datetime, timestamp_pb2.Timestamp]):
124124 """A converter for datetime.datetime types."""
125125
126126 @property
127- def python_typename (self ) -> str :
127+ def python_type (self ) -> type :
128128 """The Python type that this converter handles."""
129- return f" { dt .datetime . __module__ } . { dt . datetime . __name__ } "
129+ return dt .datetime
130130
131131 @property
132132 def protobuf_message (self ) -> Type [timestamp_pb2 .Timestamp ]:
@@ -148,9 +148,9 @@ class DTTimeDeltaConverter(Converter[dt.timedelta, duration_pb2.Duration]):
148148 """A converter for datetime.timedelta types."""
149149
150150 @property
151- def python_typename (self ) -> str :
151+ def python_type (self ) -> type :
152152 """The Python type that this converter handles."""
153- return f" { dt .timedelta . __module__ } . { dt . timedelta . __name__ } "
153+ return dt .timedelta
154154
155155 @property
156156 def protobuf_message (self ) -> Type [duration_pb2 .Duration ]:
@@ -168,13 +168,13 @@ def to_python_value(self, protobuf_message: duration_pb2.Duration) -> dt.timedel
168168 return protobuf_message .ToTimedelta ()
169169
170170
171- class BoolCollectionConverter (Converter [ Collection [ bool ] , panel_types_pb2 .BoolCollection ]):
171+ class BoolCollectionConverter (CollectionConverter [ bool , panel_types_pb2 .BoolCollection ]):
172172 """A converter for a Collection of bools."""
173173
174174 @property
175- def python_typename (self ) -> str :
175+ def item_type (self ) -> type :
176176 """The Python type that this converter handles."""
177- return f" { Collection . __name__ } . { bool . __module__ } . { bool . __name__ } "
177+ return bool
178178
179179 @property
180180 def protobuf_message (self ) -> Type [panel_types_pb2 .BoolCollection ]:
@@ -190,13 +190,13 @@ def to_python_value(self, protobuf_message: panel_types_pb2.BoolCollection) -> C
190190 return list (protobuf_message .values )
191191
192192
193- class BytesCollectionConverter (Converter [ Collection [ bytes ] , panel_types_pb2 .ByteStringCollection ]):
193+ class BytesCollectionConverter (CollectionConverter [ bytes , panel_types_pb2 .ByteStringCollection ]):
194194 """A converter for a Collection of byte strings."""
195195
196196 @property
197- def python_typename (self ) -> str :
197+ def item_type (self ) -> type :
198198 """The Python type that this converter handles."""
199- return f" { Collection . __name__ } . { bytes . __module__ } . { bytes . __name__ } "
199+ return bytes
200200
201201 @property
202202 def protobuf_message (self ) -> Type [panel_types_pb2 .ByteStringCollection ]:
@@ -216,13 +216,13 @@ def to_python_value(
216216 return list (protobuf_message .values )
217217
218218
219- class FloatCollectionConverter (Converter [ Collection [ float ] , panel_types_pb2 .FloatCollection ]):
219+ class FloatCollectionConverter (CollectionConverter [ float , panel_types_pb2 .FloatCollection ]):
220220 """A converter for a Collection of floats."""
221221
222222 @property
223- def python_typename (self ) -> str :
223+ def item_type (self ) -> type :
224224 """The Python type that this converter handles."""
225- return f" { Collection . __name__ } . { float . __module__ } . { float . __name__ } "
225+ return float
226226
227227 @property
228228 def protobuf_message (self ) -> Type [panel_types_pb2 .FloatCollection ]:
@@ -242,13 +242,13 @@ def to_python_value(
242242 return list (protobuf_message .values )
243243
244244
245- class IntCollectionConverter (Converter [ Collection [ int ] , panel_types_pb2 .IntCollection ]):
245+ class IntCollectionConverter (CollectionConverter [ int , panel_types_pb2 .IntCollection ]):
246246 """A converter for a Collection of integers."""
247247
248248 @property
249- def python_typename (self ) -> str :
249+ def item_type (self ) -> type :
250250 """The Python type that this converter handles."""
251- return f" { Collection . __name__ } . { int . __module__ } . { int . __name__ } "
251+ return int
252252
253253 @property
254254 def protobuf_message (self ) -> Type [panel_types_pb2 .IntCollection ]:
@@ -264,13 +264,13 @@ def to_python_value(self, protobuf_message: panel_types_pb2.IntCollection) -> Co
264264 return list (protobuf_message .values )
265265
266266
267- class StrCollectionConverter (Converter [ Collection [ str ] , panel_types_pb2 .StringCollection ]):
267+ class StrCollectionConverter (CollectionConverter [ str , panel_types_pb2 .StringCollection ]):
268268 """A converter for a Collection of strings."""
269269
270270 @property
271- def python_typename (self ) -> str :
271+ def item_type (self ) -> type :
272272 """The Python type that this converter handles."""
273- return f" { Collection . __name__ } . { str . __module__ } . { str . __name__ } "
273+ return str
274274
275275 @property
276276 def protobuf_message (self ) -> Type [panel_types_pb2 .StringCollection ]:
0 commit comments