25
25
from pandas ._typing import (
26
26
AnyArrayLike ,
27
27
ArrayLike ,
28
+ ArrayLikeT ,
28
29
AxisInt ,
29
30
DtypeObj ,
30
31
TakeIndexer ,
@@ -182,8 +183,8 @@ def _ensure_data(values: ArrayLike) -> np.ndarray:
182
183
183
184
184
185
def _reconstruct_data (
185
- values : ArrayLike , dtype : DtypeObj , original : AnyArrayLike
186
- ) -> ArrayLike :
186
+ values : ArrayLikeT , dtype : DtypeObj , original : AnyArrayLike
187
+ ) -> ArrayLikeT :
187
188
"""
188
189
reverse of _ensure_data
189
190
@@ -206,7 +207,9 @@ def _reconstruct_data(
206
207
# that values.dtype == dtype
207
208
cls = dtype .construct_array_type ()
208
209
209
- values = cls ._from_sequence (values , dtype = dtype )
210
+ # error: Incompatible types in assignment (expression has type
211
+ # "ExtensionArray", variable has type "ndarray[Any, Any]")
212
+ values = cls ._from_sequence (values , dtype = dtype ) # type: ignore[assignment]
210
213
211
214
else :
212
215
values = values .astype (dtype , copy = False )
@@ -259,7 +262,9 @@ def _ensure_arraylike(values, func_name: str) -> ArrayLike:
259
262
}
260
263
261
264
262
- def _get_hashtable_algo (values : np .ndarray ):
265
+ def _get_hashtable_algo (
266
+ values : np .ndarray ,
267
+ ) -> tuple [type [htable .HashTable ], np .ndarray ]:
263
268
"""
264
269
Parameters
265
270
----------
@@ -1550,7 +1555,9 @@ def safe_sort(
1550
1555
hash_klass , values = _get_hashtable_algo (values ) # type: ignore[arg-type]
1551
1556
t = hash_klass (len (values ))
1552
1557
t .map_locations (values )
1553
- sorter = ensure_platform_int (t .lookup (ordered ))
1558
+ # error: Argument 1 to "lookup" of "HashTable" has incompatible type
1559
+ # "ExtensionArray | ndarray[Any, Any] | Index | Series"; expected "ndarray"
1560
+ sorter = ensure_platform_int (t .lookup (ordered )) # type: ignore[arg-type]
1554
1561
1555
1562
if use_na_sentinel :
1556
1563
# take_nd is faster, but only works for na_sentinels of -1
0 commit comments