Skip to content

Commit f06ecff

Browse files
authored
mpy supression for caught error
1 parent 2899bca commit f06ecff

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pandas/core/missing.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,23 @@ def mask_missing(arr: ArrayLike, values_to_mask) -> npt.NDArray[np.bool_]:
124124
new_mask = np.zeros(arr.shape, dtype=np.bool_)
125125
new_mask[arr_mask] = arr[arr_mask] == x
126126
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
131131
# cases. Where a literal comparison would fail np.equal we fall back
132132
# to the original equality check.
133133
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]
135136
except TypeError:
136137
# Old behaviour for uncastable types
137138
new_mask = arr == x
138139

139140
if not isinstance(new_mask, np.ndarray):
140141
# usually BooleanArray
141142
if isinstance(new_mask, bool):
142-
new_mask = np.array([new_mask], dtype= bool)
143+
new_mask = np.array([new_mask], dtype= bool)
143144
else:
144145
new_mask = new_mask.to_numpy(dtype=bool, na_value=False)
145146
mask |= new_mask

0 commit comments

Comments
 (0)