@@ -40,18 +40,30 @@ def convert(weav_filter: Optional[_Filters]) -> Optional[base_pb2.Filters]:
4040
4141 @staticmethod
4242 def __value_filter (weav_filter : _FilterValue ) -> base_pb2 .Filters :
43+ operator = weav_filter .operator ._to_grpc ()
44+ target = _FilterToGRPC .__to_target (weav_filter .target )
45+ if isinstance (weav_filter .value , bool ):
46+ # bool is a subclass of int in Python, so we need to handle it before the int check. Also for whatever reason
47+ # the generated code from the proto files does not accept None for value_boolean, while it does for all other types.
48+ return base_pb2 .Filters (
49+ operator = operator ,
50+ value_boolean = weav_filter .value ,
51+ target = target ,
52+ )
53+
4354 return base_pb2 .Filters (
44- operator = weav_filter . operator . _to_grpc () ,
55+ operator = operator ,
4556 value_text = _FilterToGRPC .__filter_to_text (weav_filter .value ),
46- value_int = weav_filter .value if isinstance (weav_filter .value , int ) else None ,
47- value_boolean = weav_filter .value if isinstance (weav_filter .value , bool ) else None , # type: ignore
57+ value_int = weav_filter .value
58+ if isinstance (weav_filter .value , int ) and not isinstance (weav_filter .value , bool )
59+ else None ,
4860 value_number = (weav_filter .value if isinstance (weav_filter .value , float ) else None ),
61+ value_boolean_array = _FilterToGRPC .__filter_to_bool_list (weav_filter .value ),
4962 value_int_array = _FilterToGRPC .__filter_to_int_list (weav_filter .value ),
5063 value_number_array = _FilterToGRPC .__filter_to_float_list (weav_filter .value ),
5164 value_text_array = _FilterToGRPC .__filter_to_text_list (weav_filter .value ),
52- value_boolean_array = _FilterToGRPC .__filter_to_bool_list (weav_filter .value ),
5365 value_geo = _FilterToGRPC .__filter_to_geo (weav_filter .value ),
54- target = _FilterToGRPC . __to_target ( weav_filter . target ) ,
66+ target = target ,
5567 )
5668
5769 @staticmethod
@@ -137,7 +149,12 @@ def __filter_to_float_list(value: FilterValues) -> Optional[base_pb2.NumberArray
137149
138150 @staticmethod
139151 def __filter_to_int_list (value : FilterValues ) -> Optional [base_pb2 .IntArray ]:
140- if not isinstance (value , list ) or not isinstance (value [0 ], int ):
152+ # bool is a subclass of int in Python, so the check must ensure it's not a bool
153+ if (
154+ not isinstance (value , list )
155+ or not isinstance (value [0 ], int )
156+ or isinstance (value [0 ], bool )
157+ ):
141158 return None
142159
143160 return base_pb2 .IntArray (values = cast (List [int ], value ))
0 commit comments