77 without warning.
88"""
99import operator
10- from typing import Any , Callable , Dict , Optional , Sequence , Tuple , Union
10+ from typing import Any , Callable , Dict , Optional , Sequence , Tuple , Union , cast
1111
1212import numpy as np
1313
2020from pandas .util ._validators import validate_fillna_kwargs
2121
2222from pandas .core .dtypes .cast import maybe_cast_to_extension_array
23- from pandas .core .dtypes .common import is_array_like , is_list_like , pandas_dtype
23+ from pandas .core .dtypes .common import (
24+ is_array_like ,
25+ is_dtype_equal ,
26+ is_list_like ,
27+ pandas_dtype ,
28+ )
2429from pandas .core .dtypes .dtypes import ExtensionDtype
2530from pandas .core .dtypes .generic import ABCDataFrame , ABCIndexClass , ABCSeries
2631from pandas .core .dtypes .missing import isna
@@ -742,7 +747,7 @@ def searchsorted(self, value, side="left", sorter=None):
742747 arr = self .astype (object )
743748 return arr .searchsorted (value , side = side , sorter = sorter )
744749
745- def equals (self , other : "ExtensionArray" ) -> bool :
750+ def equals (self , other : object ) -> bool :
746751 """
747752 Return if another array is equivalent to this array.
748753
@@ -762,7 +767,8 @@ def equals(self, other: "ExtensionArray") -> bool:
762767 """
763768 if not type (self ) == type (other ):
764769 return False
765- elif not self .dtype == other .dtype :
770+ other = cast (ExtensionArray , other )
771+ if not is_dtype_equal (self .dtype , other .dtype ):
766772 return False
767773 elif not len (self ) == len (other ):
768774 return False
0 commit comments