@@ -176,9 +176,7 @@ def _ensure_data(values: ArrayLike) -> Tuple[np.ndarray, DtypeObj]:
176176 elif is_timedelta64_dtype (values .dtype ):
177177 from pandas import TimedeltaIndex
178178
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
182180 else :
183181 # Datetime
184182 if values .ndim > 1 and is_datetime64_ns_dtype (values .dtype ):
@@ -194,22 +192,13 @@ def _ensure_data(values: ArrayLike) -> Tuple[np.ndarray, DtypeObj]:
194192
195193 from pandas import DatetimeIndex
196194
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
200196 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
204198
205199 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
213202 dtype = pandas_dtype ("category" )
214203
215204 # we are actually coercing to int64
@@ -222,10 +211,7 @@ def _ensure_data(values: ArrayLike) -> Tuple[np.ndarray, DtypeObj]:
222211 return values , dtype # type: ignore[return-value]
223212
224213 # 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 )
229215 return ensure_object (values ), np .dtype ("object" )
230216
231217
@@ -335,9 +321,7 @@ def _get_values_for_rank(values: ArrayLike):
335321 if is_categorical_dtype (values ):
336322 values = cast ("Categorical" , values )._values_for_rank ()
337323
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 )
341325 return values
342326
343327
@@ -503,42 +487,15 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> np.ndarray:
503487 )
504488
505489 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 ))
513491 elif isinstance (values , ABCMultiIndex ):
514492 # 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 )
523494 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 )
542499 if is_extension_array_dtype (comps .dtype ):
543500 # error: Incompatible return value type (got "Series", expected "ndarray")
544501 # 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
1000957 -------
1001958 duplicated : ndarray
1002959 """
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 )
1006961 ndtype = values .dtype .name
1007962 f = getattr (htable , f"duplicated_{ ndtype } " )
1008963 return f (values , keep = keep )
0 commit comments