@@ -176,9 +176,7 @@ def _ensure_data(values: ArrayLike) -> Tuple[np.ndarray, DtypeObj]:
176
176
elif is_timedelta64_dtype (values .dtype ):
177
177
from pandas import TimedeltaIndex
178
178
179
- # error: Incompatible types in assignment (expression has type
180
- # "TimedeltaArray", variable has type "ndarray")
181
- values = TimedeltaIndex (values )._data # type: ignore[assignment]
179
+ values = TimedeltaIndex (values )._data
182
180
else :
183
181
# Datetime
184
182
if values .ndim > 1 and is_datetime64_ns_dtype (values .dtype ):
@@ -194,22 +192,13 @@ def _ensure_data(values: ArrayLike) -> Tuple[np.ndarray, DtypeObj]:
194
192
195
193
from pandas import DatetimeIndex
196
194
197
- # Incompatible types in assignment (expression has type "DatetimeArray",
198
- # variable has type "ndarray")
199
- values = DatetimeIndex (values )._data # type: ignore[assignment]
195
+ values = DatetimeIndex (values )._data
200
196
dtype = values .dtype
201
- # error: Item "ndarray" of "Union[PeriodArray, Any, ndarray]" has no attribute
202
- # "asi8"
203
- return values .asi8 , dtype # type: ignore[union-attr]
197
+ return values .asi8 , dtype
204
198
205
199
elif is_categorical_dtype (values .dtype ):
206
- # error: Incompatible types in assignment (expression has type "Categorical",
207
- # variable has type "ndarray")
208
- values = cast ("Categorical" , values ) # type: ignore[assignment]
209
- # error: Incompatible types in assignment (expression has type "ndarray",
210
- # variable has type "ExtensionArray")
211
- # error: Item "ndarray" of "Union[Any, ndarray]" has no attribute "codes"
212
- values = values .codes # type: ignore[assignment,union-attr]
200
+ values = cast ("Categorical" , values )
201
+ values = values .codes
213
202
dtype = pandas_dtype ("category" )
214
203
215
204
# we are actually coercing to int64
@@ -222,10 +211,7 @@ def _ensure_data(values: ArrayLike) -> Tuple[np.ndarray, DtypeObj]:
222
211
return values , dtype # type: ignore[return-value]
223
212
224
213
# we have failed, return object
225
-
226
- # error: Incompatible types in assignment (expression has type "ndarray", variable
227
- # has type "ExtensionArray")
228
- values = np .asarray (values , dtype = object ) # type: ignore[assignment]
214
+ values = np .asarray (values , dtype = object )
229
215
return ensure_object (values ), np .dtype ("object" )
230
216
231
217
@@ -335,9 +321,7 @@ def _get_values_for_rank(values: ArrayLike):
335
321
if is_categorical_dtype (values ):
336
322
values = cast ("Categorical" , values )._values_for_rank ()
337
323
338
- # error: Incompatible types in assignment (expression has type "ndarray", variable
339
- # has type "ExtensionArray")
340
- values , _ = _ensure_data (values ) # type: ignore[assignment]
324
+ values , _ = _ensure_data (values )
341
325
return values
342
326
343
327
@@ -503,42 +487,15 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> np.ndarray:
503
487
)
504
488
505
489
if not isinstance (values , (ABCIndex , ABCSeries , ABCExtensionArray , np .ndarray )):
506
- # error: Incompatible types in assignment (expression has type "ExtensionArray",
507
- # variable has type "Index")
508
- # error: Incompatible types in assignment (expression has type "ExtensionArray",
509
- # variable has type "Series")
510
- # error: Incompatible types in assignment (expression has type "ExtensionArray",
511
- # variable has type "ndarray")
512
- values = _ensure_arraylike (list (values )) # type: ignore[assignment]
490
+ values = _ensure_arraylike (list (values ))
513
491
elif isinstance (values , ABCMultiIndex ):
514
492
# Avoid raising in extract_array
515
-
516
- # error: Incompatible types in assignment (expression has type "ndarray",
517
- # variable has type "ExtensionArray")
518
- # error: Incompatible types in assignment (expression has type "ndarray",
519
- # variable has type "Index")
520
- # error: Incompatible types in assignment (expression has type "ndarray",
521
- # variable has type "Series")
522
- values = np .array (values ) # type: ignore[assignment]
493
+ values = np .array (values )
523
494
else :
524
- # error: Incompatible types in assignment (expression has type "Union[Any,
525
- # ExtensionArray]", variable has type "Index")
526
- # error: Incompatible types in assignment (expression has type "Union[Any,
527
- # ExtensionArray]", variable has type "Series")
528
- values = extract_array (values , extract_numpy = True ) # type: ignore[assignment]
529
-
530
- # error: Incompatible types in assignment (expression has type "ExtensionArray",
531
- # variable has type "Index")
532
- # error: Incompatible types in assignment (expression has type "ExtensionArray",
533
- # variable has type "Series")
534
- # error: Incompatible types in assignment (expression has type "ExtensionArray",
535
- # variable has type "ndarray")
536
- comps = _ensure_arraylike (comps ) # type: ignore[assignment]
537
- # error: Incompatible types in assignment (expression has type "Union[Any,
538
- # ExtensionArray]", variable has type "Index")
539
- # error: Incompatible types in assignment (expression has type "Union[Any,
540
- # ExtensionArray]", variable has type "Series")
541
- comps = extract_array (comps , extract_numpy = True ) # type: ignore[assignment]
495
+ values = extract_array (values , extract_numpy = True )
496
+
497
+ comps = _ensure_arraylike (comps )
498
+ comps = extract_array (comps , extract_numpy = True )
542
499
if is_extension_array_dtype (comps .dtype ):
543
500
# error: Incompatible return value type (got "Series", expected "ndarray")
544
501
# error: Item "ndarray" of "Union[Any, ndarray]" has no attribute "isin"
@@ -1000,9 +957,7 @@ def duplicated(values: ArrayLike, keep: Union[str, bool] = "first") -> np.ndarra
1000
957
-------
1001
958
duplicated : ndarray
1002
959
"""
1003
- # error: Incompatible types in assignment (expression has type "ndarray", variable
1004
- # has type "ExtensionArray")
1005
- values , _ = _ensure_data (values ) # type: ignore[assignment]
960
+ values , _ = _ensure_data (values )
1006
961
ndtype = values .dtype .name
1007
962
f = getattr (htable , f"duplicated_{ ndtype } " )
1008
963
return f (values , keep = keep )
0 commit comments