Skip to content

Commit 4905bd4

Browse files
committed
mypy fixup
1 parent 059f41d commit 4905bd4

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,22 +409,22 @@ def _cast_pointwise_result(self, values) -> ArrayLike:
409409
# workaround for https://github.com/apache/arrow/issues/40620
410410
result = ArrowExtensionArray._from_sequence(values)
411411
if pa.types.is_duration(self._pa_array.type):
412-
result = result.astype(self.dtype)
412+
result = result.astype(self.dtype) # type: ignore[assignment]
413413
elif pa.types.is_timestamp(self._pa_array.type):
414414
# Try to retain original unit
415415
new_dtype = ArrowDtype(pa.duration(self._pa_array.type.unit))
416416
try:
417-
result = result.astype(new_dtype)
417+
result = result.astype(new_dtype) # type: ignore[assignment]
418418
except ValueError:
419419
pass
420420
elif pa.types.is_date64(self._pa_array.type):
421421
# Try to match unit we get on non-pointwise op
422422
dtype = ArrowDtype(pa.duration("ms"))
423-
result = result.astype(dtype)
423+
result = result.astype(dtype) # type: ignore[assignment]
424424
elif pa.types.is_date(self._pa_array.type):
425425
# Try to match unit we get on non-pointwise op
426426
dtype = ArrowDtype(pa.duration("s"))
427-
result = result.astype(dtype)
427+
result = result.astype(dtype) # type: ignore[assignment]
428428
return result
429429

430430
elif pa.types.is_date(arr.type) and pa.types.is_date(self._pa_array.type):

pandas/core/arrays/masked.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def _cast_pointwise_result(self, values) -> ArrayLike:
154154
lkind = self.dtype.kind
155155
rkind = result.dtype.kind
156156
if (lkind in "iu" and rkind in "iu") or (lkind == rkind == "f"):
157+
result = cast(BaseMaskedArray, result)
157158
new_data = maybe_downcast_to_dtype(
158159
result._data, dtype=self.dtype.numpy_dtype
159160
)

pandas/core/arrays/string_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ def _cast_pointwise_result(self, values) -> ArrayLike:
729729
result = super()._cast_pointwise_result(values)
730730
if isinstance(result.dtype, StringDtype):
731731
# Ensure we retain our same na_value/storage
732-
result = result.astype(self.dtype)
732+
result = result.astype(self.dtype) # type: ignore[call-overload]
733733
return result
734734

735735
@classmethod

pandas/tests/extension/test_arrow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,9 @@ def _cast_pointwise_result(self, op_name: str, obj, other, pointwise_result):
837837
elif type(other) is float:
838838
return expected.astype("float64[pyarrow]")
839839

840-
orig_pa_type = original_dtype.pyarrow_dtype
840+
# error: Item "ExtensionDtype" of "dtype[Any] | ExtensionDtype" has
841+
# no attribute "pyarrow_dtype"
842+
orig_pa_type = original_dtype.pyarrow_dtype # type: ignore[union-attr]
841843
if not was_frame and isinstance(other, pd.Series):
842844
# i.e. test_arith_series_with_array
843845
if not (

0 commit comments

Comments
 (0)