65
65
is_timedelta64_dtype ,
66
66
needs_i8_conversion ,
67
67
)
68
+ from pandas .core .dtypes .dtypes import ExtensionDtype
68
69
from pandas .core .dtypes .generic import ABCCategoricalIndex
69
70
from pandas .core .dtypes .missing import (
70
71
isna ,
@@ -522,7 +523,7 @@ def _disallow_invalid_ops(self, values: ArrayLike, how: str):
522
523
@final
523
524
def _ea_wrap_cython_operation (
524
525
self , kind : str , values , how : str , axis : int , min_count : int = - 1 , ** kwargs
525
- ) -> Tuple [ np .ndarray , Optional [ List [ str ]]] :
526
+ ) -> np .ndarray :
526
527
"""
527
528
If we have an ExtensionArray, unwrap, call _cython_operation, and
528
529
re-wrap if appropriate.
@@ -539,10 +540,7 @@ def _ea_wrap_cython_operation(
539
540
)
540
541
if how in ["rank" ]:
541
542
# preserve float64 dtype
542
-
543
- # error: Incompatible return value type (got "ndarray", expected
544
- # "Tuple[ndarray, Optional[List[str]]]")
545
- return res_values # type: ignore[return-value]
543
+ return res_values
546
544
547
545
res_values = res_values .astype ("i8" , copy = False )
548
546
result = type (orig_values )(res_values , dtype = orig_values .dtype )
@@ -555,14 +553,11 @@ def _ea_wrap_cython_operation(
555
553
kind , values , how , axis , min_count , ** kwargs
556
554
)
557
555
dtype = maybe_cast_result_dtype (orig_values .dtype , how )
558
- if is_extension_array_dtype (dtype ):
559
- # error: Item "dtype[Any]" of "Union[dtype[Any], ExtensionDtype]" has no
560
- # attribute "construct_array_type"
561
- cls = dtype .construct_array_type () # type: ignore[union-attr]
556
+ if isinstance (dtype , ExtensionDtype ):
557
+ cls = dtype .construct_array_type ()
562
558
return cls ._from_sequence (res_values , dtype = dtype )
563
- # error: Incompatible return value type (got "ndarray", expected
564
- # "Tuple[ndarray, Optional[List[str]]]")
565
- return res_values # type: ignore[return-value]
559
+
560
+ return res_values
566
561
567
562
elif is_float_dtype (values .dtype ):
568
563
# FloatingArray
@@ -599,9 +594,7 @@ def _cython_operation(
599
594
self ._disallow_invalid_ops (values , how )
600
595
601
596
if is_extension_array_dtype (values .dtype ):
602
- # error: Incompatible return value type (got "Tuple[ndarray,
603
- # Optional[List[str]]]", expected "ndarray")
604
- return self ._ea_wrap_cython_operation ( # type: ignore[return-value]
597
+ return self ._ea_wrap_cython_operation (
605
598
kind , values , how , axis , min_count , ** kwargs
606
599
)
607
600
0 commit comments