Skip to content

STYLE enable ruff PLW2901 #51708

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

Closed
MarcoGorelli opened this issue Mar 1, 2023 · 9 comments · Fixed by #51797
Closed

STYLE enable ruff PLW2901 #51708

MarcoGorelli opened this issue Mar 1, 2023 · 9 comments · Fixed by #51797
Assignees
Labels
Code Style Code style, linting, code_checks good first issue

Comments

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Mar 1, 2023

Task is:

  1. check the contributing guide for how to set up your environment
  2. remove PLW2901 from

pandas/pyproject.toml

Lines 272 to 273 in 2c10d93

# Outer loop variable overwritten by inner assignment
"PLW2901",

  1. run pre-commit run ruff --all-files
  2. fixup the errors it flags - see https://beta.ruff.rs/docs/rules/redefined-loop-name/ for more info on this error
  3. stage, commit, push, open pull request
@MarcoGorelli MarcoGorelli added Code Style Code style, linting, code_checks good first issue labels Mar 1, 2023
@MarcoGorelli MarcoGorelli modified the milestone: 2.1 Mar 1, 2023
@ErdiTk
Copy link
Contributor

ErdiTk commented Mar 1, 2023

Hi Marco, may I help for this issue?

@MarcoGorelli
Copy link
Member Author

sure, go ahead

@ErdiTk
Copy link
Contributor

ErdiTk commented Mar 1, 2023

Take

@ErdiTk
Copy link
Contributor

ErdiTk commented Mar 2, 2023

After removing it and running pre-commit run ruff --all-files, I found 186 errors. I will start tackling them by tomorrow. Shall I go over them one by one right? Seems like the issue is as described in your link.
If I add the following line of code (based on your comment on #51709 ) the amount of errors goes to 125:
"pandas/core/*" = ["PLR5501"]

@MarcoGorelli
Copy link
Member Author

yeah sounds good - and feel free to ignore other folders too if the number of remaining issues is too many

@ErdiTk
Copy link
Contributor

ErdiTk commented Mar 3, 2023

I grouped the issues under the "to be gradually enabled" section and resolved the isolated once. Unfortunately today I had limited time to dedicate to it. The changes seems to be a renaming of the variables which get overwritten. I can continue and do all of them if that's fine for you. For now I changed something like this:

for foo in bar:
    foo = function_x()
return foo

Into this:

for foo in bar:   
    foo_new = function_x()
return foo_new

Please let me know if you think there is another approach for it.

@ErdiTk ErdiTk mentioned this issue Mar 5, 2023
3 tasks
@ErdiTk
Copy link
Contributor

ErdiTk commented Mar 5, 2023

I generated the PR to show you the changes. If it's fine for you I can update the PR by continuing the resolution of "to be gradually enabled" items I added.

@The-Nesh
Copy link

Hi Marco, can you please explain why this issue was reopened? I would like to help with it. Thanks!

@MarcoGorelli
Copy link
Member Author

It was probably an accident - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants