-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Fix pylint undefined-loop-variable warnings #49740
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
Changes from 1 commit
d7bab20
8c91f39
fc6998e
4f0e90d
297889e
ed65d3d
10b612a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -883,7 +883,7 @@ def parse( | |
if ret_dict: | ||
return output | ||
else: | ||
return output[asheetname] | ||
return output[asheetname] # pylint: disable=undefined-loop-variable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about this one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that the key here is the sequence of conditional statements that start in line 715. In the first two cases, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a way to refactor such as to not have to turn off the warning? the warning is there because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aside from being a silly example, is this an undesired pattern?
Here the loop variable is guaranteed to exist after the for-loop (the same as in this code here). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's just to help prevent Edge cases like
in which There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then I think it's okay to disable the warning in this case (the for loop is guaranteed to be entered). I'm also very much in favor of refactoring this code, but for reasons outside of the scope of this issue. |
||
|
||
|
||
@doc(storage_options=_shared_docs["storage_options"]) | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -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:]] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 pandas/pandas/tests/frame/test_iteration.py Line 162 in d7bab20
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||||
|
||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2298,6 +2298,7 @@ def set_sticky( | |
"selector": f"thead tr:nth-child({obj.nlevels+1}) th", | ||
"props": props | ||
+ ( | ||
# pylint: disable=undefined-loop-variable | ||
f"top:{(i+1) * pixel_size}px; height:{pixel_size}px; " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what's going on in this file. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's just that it's outside of the loop |
||
"z-index:2;" | ||
), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,7 @@ def test_publishes(self, ip): | |
with_latex = pd.option_context("display.latex.repr", True) | ||
|
||
with opt, with_latex: | ||
# pylint: disable-next=undefined-loop-variable | ||
formatted = ipython.display_formatter.format(obj) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the help! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're welcome! |
||
|
||
expected = { | ||
|
Uh oh!
There was an error while loading. Please reload this page.