Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: Fix pylint undefined-loop-variable warnings #49740

Merged
merged 7 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pandas/io/formats/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ def _get_strcols(self) -> list[list[str]]:
def pad_empties(x):
for pad in reversed(x):
if pad:
break
return [x[0]] + [i if i else " " * len(pad) for i in x[1:]]
return [x[0]] + [i if i else " " * len(pad) for i in x[1:]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's reasonable. But I also want to change the variable s in this test to col. I think the current variable probably a mistake that this warning brought to my attention.

str(s) # pylint: disable=undefined-loop-variable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah sounds good - looks like the test is just there to check that iteration works anyway


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

Expand Down
4 changes: 2 additions & 2 deletions pandas/io/formats/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ def best_len(values: list[str]) -> int:
for max_items in reversed(range(1, len(value) + 1)):
pprinted_seq = _pprint_seq(value, max_seq_items=max_items)
if len(pprinted_seq) < max_space:
head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]
break
head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]

summary = ""
line = space2
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -2298,8 +2298,8 @@ def set_sticky(
"selector": f"thead tr:nth-child({obj.nlevels+1}) th",
"props": props
+ (
f"top:{(i+1) * pixel_size}px; height:{pixel_size}px; "
"z-index:2;"
f"top:{(len(levels_)) * pixel_size}px; "
f"height:{pixel_size}px; z-index:2;"
),
}
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_iteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ def test_sequence_like_with_categorical(self):
str(s)

for c, col in df.items():
str(s)
str(col)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ disable = [
"too-many-public-methods",
"too-many-return-statements",
"too-many-statements",
"undefined-loop-variable",
"unexpected-keyword-arg",
"ungrouped-imports",
"unsubscriptable-object",
Expand Down Expand Up @@ -277,7 +278,6 @@ disable = [
"signature-differs",
"super-init-not-called",
"try-except-raise",
"undefined-loop-variable",
"unnecessary-lambda",
"unspecified-encoding",
"unused-argument",
Expand Down