Skip to content

Commit d7bab20

Browse files
committed
CLN: Fix pylint undefined-loop-variable warnings
1 parent bf676a2 commit d7bab20

File tree

9 files changed

+11
-8
lines changed

9 files changed

+11
-8
lines changed

pandas/core/util/hashing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def combine_hash_arrays(
7676
out ^= a
7777
out *= mult
7878
mult += np.uint64(82520 + inverse_i + inverse_i)
79-
assert i + 1 == num_items, "Fed in wrong num_items"
79+
assert len(arrays) == num_items, "Fed in wrong num_items"
8080
out += np.uint64(97531)
8181
return out
8282

pandas/io/excel/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ def parse(
883883
if ret_dict:
884884
return output
885885
else:
886-
return output[asheetname]
886+
return output[asheetname] # pylint: disable=undefined-loop-variable
887887

888888

889889
@doc(storage_options=_shared_docs["storage_options"])

pandas/io/formats/latex.py

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ def best_len(values: list[str]) -> int:
419419
for max_items in reversed(range(1, len(value) + 1)):
420420
pprinted_seq = _pprint_seq(value, max_seq_items=max_items)
421421
if len(pprinted_seq) < max_space:
422+
head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
423+
tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]
422424
break
423-
head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
424-
tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]
425425

426426
summary = ""
427427
line = space2

pandas/io/formats/style.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,6 +2298,7 @@ def set_sticky(
22982298
"selector": f"thead tr:nth-child({obj.nlevels+1}) th",
22992299
"props": props
23002300
+ (
2301+
# pylint: disable=undefined-loop-variable
23012302
f"top:{(i+1) * pixel_size}px; height:{pixel_size}px; "
23022303
"z-index:2;"
23032304
),

pandas/tests/frame/methods/test_to_dict_of_blocks.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_copy_blocks(self, float_frame):
2525
_df.loc[:, column] = _df[column] + 1
2626

2727
# make sure we did not change the original DataFrame
28+
# pylint: disable-next=undefined-loop-variable
2829
assert not _df[column].equals(df[column])
2930

3031
def test_no_copy_blocks(self, float_frame, using_copy_on_write):
@@ -40,8 +41,10 @@ def test_no_copy_blocks(self, float_frame, using_copy_on_write):
4041

4142
if not using_copy_on_write:
4243
# make sure we did change the original DataFrame
44+
# pylint: disable-next=undefined-loop-variable
4345
assert _df[column].equals(df[column])
4446
else:
47+
# pylint: disable-next=undefined-loop-variable
4548
assert not _df[column].equals(df[column])
4649

4750

pandas/tests/frame/test_iteration.py

Lines changed: 1 addition & 1 deletion
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(s) # pylint: disable=undefined-loop-variable

pandas/tests/io/formats/test_printing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def test_publishes(self, ip):
141141
with_latex = pd.option_context("display.latex.repr", True)
142142

143143
with opt, with_latex:
144+
# pylint: disable-next=undefined-loop-variable
144145
formatted = ipython.display_formatter.format(obj)
145146

146147
expected = {

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ disable = [
153153
"subprocess-run-check",
154154
"super-init-not-called",
155155
"try-except-raise",
156-
"undefined-loop-variable",
157156
"unnecessary-lambda",
158157
"unspecified-encoding",
159158
"unused-argument",

0 commit comments

Comments
 (0)