Skip to content

Commit b652e1d

Browse files
committed
Fix type inference issues by adding type ignores in various files and refactor dictionary creation for clarity
1 parent dc1a6d2 commit b652e1d

File tree

11 files changed

+13
-15
lines changed

11 files changed

+13
-15
lines changed

src/xlviews/core/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __len__(self) -> int:
6262

6363
@property
6464
def names(self) -> list[str]:
65-
return self.index.names
65+
return self.index.names # type: ignore
6666

6767
@property
6868
def nlevels(self) -> int:

src/xlviews/dataframes/dist_frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def get_init_data(index: Index, columns: list[str]) -> DataFrame:
199199

200200
def get_dist_func(dist: str | dict[str, str], columns: list[str]) -> dict[str, str]:
201201
if isinstance(dist, str):
202-
return {column: dist for column in columns}
202+
return dict.fromkeys(columns, dist)
203203

204204
dist = dist.copy()
205205
for column in columns:

src/xlviews/dataframes/heat_frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(
4242

4343
super().__init__(row, column, data, sheet)
4444

45-
self.columns = data.columns
45+
self.columns = data.columns # type: ignore
4646

4747
start = self.row + 1, self.column + 1
4848
end = start[0] + self.shape[0] - 1, start[1] + self.shape[1] - 1

src/xlviews/dataframes/sheet_frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,8 @@ def number_format(
612612
continue
613613

614614
for pattern, number_format in columns_format.items():
615-
if re.match(pattern, column):
616-
rng = self.get_range(column).impl
615+
if re.match(pattern, column): # type: ignore
616+
rng = self.get_range(column).impl # type: ignore
617617
rng.number_format = number_format
618618
if autofit:
619619
rng.autofit()

src/xlviews/dataframes/stats_frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def get_func(func: str | list[str] | None) -> list[str]:
8181

8282
def get_by(sf: SheetFrame, by: str | list[str] | None) -> list[str]:
8383
if not by:
84-
return sf.index.names
84+
return sf.index.names # type: ignore
8585

8686
return list(iter_columns(sf.index.names, by))
8787

@@ -142,7 +142,7 @@ def set_style(sf: SheetFrame, parent: SheetFrame, func_column_name: str) -> None
142142
idx = [sf.column + i for i in range(sf.index.nlevels + len(sf.columns))]
143143

144144
columns = (*parent.index.names, *parent.columns)
145-
formats = [None, *[parent.get_number_format(column) for column in columns]]
145+
formats = [None, *[parent.get_number_format(column) for column in columns]] # type: ignore
146146

147147
for (func,), rows in sf.groupby(func_column_name).items():
148148
for col, fmt in zip(idx, formats, strict=True):

src/xlviews/dataframes/table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def auto_filter(self, *args, clear: bool = False, **field_criteria) -> None:
118118
- other: specify the value.
119119
"""
120120
if clear:
121-
clear_filter = {x: None for x in self.columns}
121+
clear_filter = dict.fromkeys(self.columns)
122122
clear_filter.update(field_criteria)
123123
field_criteria = clear_filter
124124

src/xlviews/figure/grid.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ def __getitem__(self, key: int) -> Series: ...
9898
@overload
9999
def __getitem__(self, key: tuple[int, int]) -> Axes: ...
100100

101-
@overload
102-
def __getitem__(self, key: tuple[int, int]) -> Axes: ...
103-
104101
@overload
105102
def __getitem__(self, key: tuple[slice, int]) -> Series: ...
106103

src/xlviews/figure/palette.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ def get_palette(
186186

187187
if isinstance(style, Callable):
188188
if isinstance(data.index, MultiIndex):
189-
return FunctionPalette(data.index.names, style)
190-
return FunctionPalette(data.index.name, style)
189+
return FunctionPalette(data.index.names, style) # type: ignore
190+
return FunctionPalette(data.index.name, style) # type: ignore
191191

192192
if data.index.name is not None or isinstance(data.index, MultiIndex):
193193
data = data.index.to_frame(index=False)

src/xlviews/figure/plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def keys(self) -> Iterator[dict[str, Hashable]]:
5858
names = self.data.index.names
5959

6060
for index in self.index:
61-
yield dict(zip(names, index, strict=True))
61+
yield dict(zip(names, index, strict=True)) # type: ignore
6262

6363
def set(
6464
self,

src/xlviews/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ def suspend_screen_updates(func: Callable[P, R]) -> Callable[P, R]:
128128

129129
@wraps(func)
130130
def _func(*args: P.args, **kwargs: P.kwargs) -> R:
131+
is_updating = False
132+
131133
if app := xlwings.apps.active:
132134
is_updating = app.screen_updating
133135
app.screen_updating = False

0 commit comments

Comments
 (0)