Skip to content

Commit b48735a

Browse files
fabincacarlotta
and
carlotta
authored
STYLE: fix pylint consider-using-get warnings (#49334)
resolved this pylint error Co-authored-by: carlotta <[email protected]>
1 parent db1b458 commit b48735a

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

pandas/io/excel/_openpyxl.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ def _convert_to_style_kwargs(cls, style_dict: dict) -> dict[str, Serialisable]:
139139

140140
style_kwargs: dict[str, Serialisable] = {}
141141
for k, v in style_dict.items():
142-
if k in _style_key_map:
143-
k = _style_key_map[k]
142+
k = _style_key_map.get(k, k)
144143
_conv_to_x = getattr(cls, f"_convert_to_{k}", lambda x: None)
145144
new_v = _conv_to_x(v)
146145
if new_v:
@@ -218,8 +217,7 @@ def _convert_to_font(cls, font_dict):
218217

219218
font_kwargs = {}
220219
for k, v in font_dict.items():
221-
if k in _font_key_map:
222-
k = _font_key_map[k]
220+
k = _font_key_map.get(k, k)
223221
if k == "color":
224222
v = cls._convert_to_color(v)
225223
font_kwargs[k] = v
@@ -288,11 +286,8 @@ def _convert_to_fill(cls, fill_dict: dict[str, Any]):
288286
pfill_kwargs = {}
289287
gfill_kwargs = {}
290288
for k, v in fill_dict.items():
291-
pk = gk = None
292-
if k in _pattern_fill_key_map:
293-
pk = _pattern_fill_key_map[k]
294-
if k in _gradient_fill_key_map:
295-
gk = _gradient_fill_key_map[k]
289+
pk = _pattern_fill_key_map.get(k)
290+
gk = _gradient_fill_key_map.get(k)
296291
if pk in ["start_color", "end_color"]:
297292
v = cls._convert_to_color(v)
298293
if gk == "stop":
@@ -336,8 +331,7 @@ def _convert_to_side(cls, side_spec):
336331

337332
side_kwargs = {}
338333
for k, v in side_spec.items():
339-
if k in _side_key_map:
340-
k = _side_key_map[k]
334+
k = _side_key_map.get(k, k)
341335
if k == "color":
342336
v = cls._convert_to_color(v)
343337
side_kwargs[k] = v
@@ -375,8 +369,7 @@ def _convert_to_border(cls, border_dict):
375369

376370
border_kwargs = {}
377371
for k, v in border_dict.items():
378-
if k in _border_key_map:
379-
k = _border_key_map[k]
372+
k = _border_key_map.get(k, k)
380373
if k == "color":
381374
v = cls._convert_to_color(v)
382375
if k in ["left", "right", "top", "bottom", "diagonal"]:

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ disable = [
109109
"comparison-with-itself",
110110
"consider-merging-isinstance",
111111
"consider-using-from-import",
112-
"consider-using-get",
113112
"consider-using-min-builtin",
114113
"consider-using-sys-exit",
115114
"consider-using-ternary",

0 commit comments

Comments
 (0)