Skip to content

Commit c010752

Browse files
fangchenliKevin D Smith
authored and
Kevin D Smith
committed
TYP: add type annotation to _xlwt.py pandas-dev#36024 (pandas-dev#36025)
1 parent ab11b92 commit c010752

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

pandas/io/excel/_xlwt.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
from typing import TYPE_CHECKING, Dict
2+
13
import pandas._libs.json as json
24

35
from pandas.io.excel._base import ExcelWriter
46
from pandas.io.excel._util import _validate_freeze_panes
57

8+
if TYPE_CHECKING:
9+
from xlwt import XFStyle
10+
611

712
class _XlwtWriter(ExcelWriter):
813
engine = "xlwt"
@@ -29,12 +34,11 @@ def save(self):
2934
"""
3035
Save workbook to disk.
3136
"""
32-
return self.book.save(self.path)
37+
self.book.save(self.path)
3338

3439
def write_cells(
3540
self, cells, sheet_name=None, startrow=0, startcol=0, freeze_panes=None
3641
):
37-
# Write the frame cells using xlwt.
3842

3943
sheet_name = self._get_sheet_name(sheet_name)
4044

@@ -49,7 +53,7 @@ def write_cells(
4953
wks.set_horz_split_pos(freeze_panes[0])
5054
wks.set_vert_split_pos(freeze_panes[1])
5155

52-
style_dict = {}
56+
style_dict: Dict[str, XFStyle] = {}
5357

5458
for cell in cells:
5559
val, fmt = self._value_with_fmt(cell.val)
@@ -101,14 +105,14 @@ def _style_to_xlwt(
101105
f"{key}: {cls._style_to_xlwt(value, False)}"
102106
for key, value in item.items()
103107
]
104-
out = f"{(line_sep).join(it)} "
108+
out = f"{line_sep.join(it)} "
105109
return out
106110
else:
107111
it = [
108112
f"{key} {cls._style_to_xlwt(value, False)}"
109113
for key, value in item.items()
110114
]
111-
out = f"{(field_sep).join(it)} "
115+
out = f"{field_sep.join(it)} "
112116
return out
113117
else:
114118
item = f"{item}"

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ check_untyped_defs=False
223223
[mypy-pandas.io.excel._util]
224224
check_untyped_defs=False
225225

226-
[mypy-pandas.io.excel._xlwt]
227-
check_untyped_defs=False
228-
229226
[mypy-pandas.io.formats.console]
230227
check_untyped_defs=False
231228

0 commit comments

Comments
 (0)