@@ -124,22 +124,23 @@ def mask_missing(arr: ArrayLike, values_to_mask) -> npt.NDArray[np.bool_]:
124
124
new_mask = np .zeros (arr .shape , dtype = np .bool_ )
125
125
new_mask [arr_mask ] = arr [arr_mask ] == x
126
126
else :
127
- # GH#47101
128
- # Fix where type bool has no attribute to_numpy() by first
129
- # attempting to broadcast with np.equal for some cases, and then
130
- # an explicit type check when checking the mask for any straggling
127
+ # GH#47101
128
+ # Fix where type bool has no attribute to_numpy() by first
129
+ # attempting to broadcast with np.equal for some cases, and then
130
+ # an explicit type check when checking the mask for any straggling
131
131
# cases. Where a literal comparison would fail np.equal we fall back
132
132
# to the original equality check.
133
133
try :
134
- new_mask = np .equal (arr , x )
134
+ # In case of an uncastable type, this will emit TypeError
135
+ new_mask = np .equal (arr , x ) # type: ignore[arg-type]
135
136
except TypeError :
136
137
# Old behaviour for uncastable types
137
138
new_mask = arr == x
138
139
139
140
if not isinstance (new_mask , np .ndarray ):
140
141
# usually BooleanArray
141
142
if isinstance (new_mask , bool ):
142
- new_mask = np .array ([new_mask ], dtype = bool )
143
+ new_mask = np .array ([new_mask ], dtype = bool )
143
144
else :
144
145
new_mask = new_mask .to_numpy (dtype = bool , na_value = False )
145
146
mask |= new_mask
0 commit comments