Skip to content

Commit 6c0d228

Browse files
fix dtype equality in case pyarrow is not installed
1 parent a4c9d4a commit 6c0d228

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

pandas/core/arrays/string_.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ def __eq__(self, other: object) -> bool:
167167
return True
168168
try:
169169
other = self.construct_from_string(other)
170-
except TypeError:
170+
except (TypeError, ImportError):
171+
# TypeError if `other` is not a valid string for StringDtype
172+
# ImportError if pyarrow is not installed for "string[pyarrow]"
171173
return False
172174
if isinstance(other, type(self)):
173175
return self.storage == other.storage and self.na_value is other.na_value

pandas/tests/dtypes/test_common.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import numpy as np
44
import pytest
55

6-
from pandas._config import using_string_dtype
7-
86
import pandas.util._test_decorators as td
97

108
from pandas.core.dtypes.astype import astype_array
@@ -130,7 +128,6 @@ def test_dtype_equal(name1, dtype1, name2, dtype2):
130128
assert not com.is_dtype_equal(dtype1, dtype2)
131129

132130

133-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
134131
@pytest.mark.parametrize("name,dtype", list(dtypes.items()), ids=lambda x: str(x))
135132
def test_pyarrow_string_import_error(name, dtype):
136133
# GH-44276

0 commit comments

Comments
 (0)