Skip to content

Commit

Permalink
TYP: fix incorrect mypy error in reshape.py (pandas-dev#45127)
Browse files Browse the repository at this point in the history
  • Loading branch information
kashifkhan authored Dec 31, 2021
1 parent e750c94 commit fa3d5f1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pandas/core/reshape/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
Index,
MultiIndex,
)
from pandas.core.indexes.frozen import FrozenList
from pandas.core.series import Series
from pandas.core.sorting import (
compress_group_index,
Expand Down Expand Up @@ -316,15 +317,16 @@ def get_new_columns(self, value_columns: Index | None):
stride = len(self.removed_level) + self.lift
width = len(value_columns)
propagator = np.repeat(np.arange(width), stride)

new_levels: FrozenList | list[Index]

if isinstance(value_columns, MultiIndex):
new_levels = value_columns.levels + (self.removed_level_full,)
new_names = value_columns.names + (self.removed_name,)

new_codes = [lab.take(propagator) for lab in value_columns.codes]
else:
# error: Incompatible types in assignment (expression has type "List[Any]",
# variable has type "FrozenList")
new_levels = [ # type: ignore[assignment]
new_levels = [
value_columns,
self.removed_level_full,
]
Expand Down

0 comments on commit fa3d5f1

Please sign in to comment.