From d0051955a83feb393fad49ded8fd340d18d5686c Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 12 Jan 2025 20:25:34 -0500 Subject: [PATCH 1/4] TST(str dtype): Resolve xfail for unary + --- pandas/core/arrays/string_arrow.py | 4 ++++ pandas/tests/frame/test_unary.py | 6 ------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pandas/core/arrays/string_arrow.py b/pandas/core/arrays/string_arrow.py index 27c1425d11ac6..a3338a6460a8c 100644 --- a/pandas/core/arrays/string_arrow.py +++ b/pandas/core/arrays/string_arrow.py @@ -4,6 +4,7 @@ import re from typing import ( TYPE_CHECKING, + Never, Union, ) import warnings @@ -481,6 +482,9 @@ def _cmp_method(self, other, op): return result.to_numpy(np.bool_, na_value=False) return result + def __pos__(self) -> Never: + raise TypeError(f"bad operand type for unary +: '{self.dtype}'") + class ArrowStringArrayNumpySemantics(ArrowStringArray): _na_value = np.nan diff --git a/pandas/tests/frame/test_unary.py b/pandas/tests/frame/test_unary.py index 217255e73b450..652f52bd226af 100644 --- a/pandas/tests/frame/test_unary.py +++ b/pandas/tests/frame/test_unary.py @@ -3,9 +3,6 @@ import numpy as np import pytest -from pandas._config import using_string_dtype - -from pandas.compat import HAS_PYARROW from pandas.compat.numpy import np_version_gte1p25 import pandas as pd @@ -122,9 +119,6 @@ def test_pos_object(self, df_data): tm.assert_frame_equal(+df, df) tm.assert_series_equal(+df["a"], df["a"]) - @pytest.mark.xfail( - using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)" - ) @pytest.mark.filterwarnings("ignore:Applying:DeprecationWarning") def test_pos_object_raises(self): # GH#21380 From 6c8b916be9024005ddf0bea27b72e3b91f802db7 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 12 Jan 2025 20:30:39 -0500 Subject: [PATCH 2/4] whatsnew --- doc/source/whatsnew/v2.3.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v2.3.0.rst b/doc/source/whatsnew/v2.3.0.rst index b107a5d3ba100..971760a64b662 100644 --- a/doc/source/whatsnew/v2.3.0.rst +++ b/doc/source/whatsnew/v2.3.0.rst @@ -105,6 +105,7 @@ Conversion Strings ^^^^^^^ +- Bug in :meth:`Series.__pos__` and :meth:`DataFrame.__pos__` did not raise for :class:`StringDtype` with ``storage="pyarrow"`` (:issue:`60710`) - Bug in :meth:`Series.rank` for :class:`StringDtype` with ``storage="pyarrow"`` incorrectly returning integer results in case of ``method="average"`` and raising an error if it would truncate results (:issue:`59768`) - Bug in :meth:`Series.replace` with :class:`StringDtype` when replacing with a non-string value was not upcasting to ``object`` dtype (:issue:`60282`) - Bug in :meth:`Series.str.replace` when ``n < 0`` for :class:`StringDtype` with ``storage="pyarrow"`` (:issue:`59628`) From 50d97d1e84072351c410eb542985a2168390229d Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 13 Jan 2025 21:54:28 -0500 Subject: [PATCH 3/4] Never -> None --- pandas/core/arrays/string_arrow.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/arrays/string_arrow.py b/pandas/core/arrays/string_arrow.py index a3338a6460a8c..d514ff7a2c93f 100644 --- a/pandas/core/arrays/string_arrow.py +++ b/pandas/core/arrays/string_arrow.py @@ -4,7 +4,6 @@ import re from typing import ( TYPE_CHECKING, - Never, Union, ) import warnings @@ -482,7 +481,7 @@ def _cmp_method(self, other, op): return result.to_numpy(np.bool_, na_value=False) return result - def __pos__(self) -> Never: + def __pos__(self) -> None: raise TypeError(f"bad operand type for unary +: '{self.dtype}'") From 23993c92860b4ee726cac6d6e9297d23bb96f666 Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 21 Jan 2025 21:11:34 -0500 Subject: [PATCH 4/4] Fix type-hint --- pandas/core/arrays/string_arrow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/arrays/string_arrow.py b/pandas/core/arrays/string_arrow.py index d514ff7a2c93f..d35083fd892a8 100644 --- a/pandas/core/arrays/string_arrow.py +++ b/pandas/core/arrays/string_arrow.py @@ -481,7 +481,7 @@ def _cmp_method(self, other, op): return result.to_numpy(np.bool_, na_value=False) return result - def __pos__(self) -> None: + def __pos__(self) -> Self: raise TypeError(f"bad operand type for unary +: '{self.dtype}'")