Skip to content

Commit c8bde1d

Browse files
natmokvalim-vinicius
authored and
im-vinicius
committed
TYP: remove mypy ignore[assignment] from pandas/core/internals/construction.py (pandas-dev#53135)
* remove mypy ignore[assignment] * replace casting with refactoring
1 parent 245bbc4 commit c8bde1d

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pandas/core/internals/construction.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,7 @@ def reorder_arrays(
675675
if columns is not None:
676676
if not columns.equals(arr_columns):
677677
# if they are equal, there is nothing to do
678-
new_arrays: list[ArrayLike | None]
679-
new_arrays = [None] * len(columns)
678+
new_arrays: list[ArrayLike] = []
680679
indexer = arr_columns.get_indexer(columns)
681680
for i, k in enumerate(indexer):
682681
if k == -1:
@@ -685,12 +684,9 @@ def reorder_arrays(
685684
arr.fill(np.nan)
686685
else:
687686
arr = arrays[k]
688-
new_arrays[i] = arr
687+
new_arrays.append(arr)
689688

690-
# Incompatible types in assignment (expression has type
691-
# "List[Union[ExtensionArray, ndarray[Any, Any], None]]", variable
692-
# has type "List[Union[ExtensionArray, ndarray[Any, Any]]]")
693-
arrays = new_arrays # type: ignore[assignment]
689+
arrays = new_arrays
694690
arr_columns = columns
695691

696692
return arrays, arr_columns

0 commit comments

Comments
 (0)