From f31e0814477710e3013c1260477d5257fc219cd2 Mon Sep 17 00:00:00 2001 From: Kashif Khan <200~361477+kashifkhan@users.noreply.github.com> Date: Fri, 31 Dec 2021 10:33:01 -0600 Subject: [PATCH] TYP: define gen and gen2 as Iterable --- pandas/io/formats/excel.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/io/formats/excel.py b/pandas/io/formats/excel.py index 1f1ca434a22c0..a049d6a08a29f 100644 --- a/pandas/io/formats/excel.py +++ b/pandas/io/formats/excel.py @@ -649,20 +649,21 @@ def _format_header_regular(self) -> Iterable[ExcelCell]: ) def _format_header(self) -> Iterable[ExcelCell]: + gen: Iterable[ExcelCell] + if isinstance(self.columns, MultiIndex): gen = self._format_header_mi() else: gen = self._format_header_regular() - gen2 = () + gen2: Iterable[ExcelCell] = () + if self.df.index.names: row = [x if x is not None else "" for x in self.df.index.names] + [ "" ] * len(self.columns) if reduce(lambda x, y: x and y, map(lambda x: x != "", row)): - # error: Incompatible types in assignment (expression has type - # "Generator[ExcelCell, None, None]", variable has type "Tuple[]") - gen2 = ( # type: ignore[assignment] + gen2 = ( ExcelCell(self.rowcounter, colindex, val, self.header_style) for colindex, val in enumerate(row) )