diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 4c6a32ff1ba4e..16fcf6daf5aef 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -421,13 +421,8 @@ def __init__( if null_mask.any(): # We remove null values here, then below will re-insert # them, grep "full_codes" - - # error: Incompatible types in assignment (expression has type - # "List[Any]", variable has type "ExtensionArray") - arr = [ # type: ignore[assignment] - values[idx] for idx in np.where(~null_mask)[0] - ] - arr = sanitize_array(arr, None) + arr_list = [values[idx] for idx in np.where(~null_mask)[0]] + arr = sanitize_array(arr_list, None) values = arr if dtype.categories is None: diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index e20670893f71c..71da0a4b20b41 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -465,9 +465,7 @@ def _hash_categories(self) -> int: [cat_array, np.arange(len(cat_array), dtype=cat_array.dtype)] ) else: - # error: Incompatible types in assignment (expression has type - # "List[ndarray]", variable has type "ndarray") - cat_array = [cat_array] # type: ignore[assignment] + cat_array = np.array([cat_array]) combined_hashed = combine_hash_arrays(iter(cat_array), num_items=len(cat_array)) return np.bitwise_xor.reduce(combined_hashed)