Skip to content

Commit 3c55eee

Browse files
authored
CLN: Fix pylint undefined-loop-variable warnings (#49740)
* CLN: Fix pylint undefined-loop-variable warnings * Fix undefined-loop-variable pylint warning * CLN: Format props f-strings for clarity
1 parent d800024 commit 3c55eee

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

pandas/io/formats/latex.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ def _get_strcols(self) -> list[list[str]]:
160160
def pad_empties(x):
161161
for pad in reversed(x):
162162
if pad:
163-
break
164-
return [x[0]] + [i if i else " " * len(pad) for i in x[1:]]
163+
return [x[0]] + [i if i else " " * len(pad) for i in x[1:]]
165164

166165
gen = (pad_empties(i) for i in out)
167166

pandas/io/formats/printing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ def best_len(values: list[str]) -> int:
417417
for max_items in reversed(range(1, len(value) + 1)):
418418
pprinted_seq = _pprint_seq(value, max_seq_items=max_items)
419419
if len(pprinted_seq) < max_space:
420+
head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
421+
tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]
420422
break
421-
head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
422-
tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]
423423

424424
summary = ""
425425
line = space2

pandas/io/formats/style.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2304,8 +2304,8 @@ def set_sticky(
23042304
"selector": f"thead tr:nth-child({obj.nlevels+1}) th",
23052305
"props": props
23062306
+ (
2307-
f"top:{(i+1) * pixel_size}px; height:{pixel_size}px; "
2308-
"z-index:2;"
2307+
f"top:{(len(levels_)) * pixel_size}px; "
2308+
f"height:{pixel_size}px; z-index:2;"
23092309
),
23102310
}
23112311
)

pandas/tests/frame/test_iteration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,4 @@ def test_sequence_like_with_categorical(self):
159159
str(s)
160160

161161
for c, col in df.items():
162-
str(s)
162+
str(col)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ disable = [
217217
"too-many-public-methods",
218218
"too-many-return-statements",
219219
"too-many-statements",
220+
"undefined-loop-variable",
220221
"unexpected-keyword-arg",
221222
"ungrouped-imports",
222223
"unsubscriptable-object",
@@ -276,7 +277,6 @@ disable = [
276277
"signature-differs",
277278
"super-init-not-called",
278279
"try-except-raise",
279-
"undefined-loop-variable",
280280
"unnecessary-lambda",
281281
"unspecified-encoding",
282282
"unused-argument",

0 commit comments

Comments
 (0)