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

Avoid unused loop control variable or name them _ (B007) #6813

Merged
merged 1 commit into from
Aug 1, 2022

Conversation

hendrikmakait
Copy link
Member

@hendrikmakait hendrikmakait commented Aug 1, 2022

Partially addresses pre-commit failures in #6809

Note:

I'm a bit torn when it comes to this rule. In a number of instances, it improved the code by removing unnecessary variables, but in other instances, the value of for _ in range(N) over for i in range(N) is marginal and may be considered an unnecessary restriction by some developers.

  • Tests added / passed
  • Passes pre-commit run --all-files

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2022

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

       15 files  ±  0         15 suites  ±0   6h 13m 6s ⏱️ - 14m 12s
  2 983 tests ±  0    2 893 ✔️ +  4       88 💤 +  1  2  - 3 
22 128 runs  +14  21 036 ✔️  - 39  1 085 💤 +57  7  - 2 

For more details on these failures, see this check.

Results for commit 8dacd3f. ± Comparison against base commit 9267a21.

Copy link
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

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

Thanks @hendrikmakait

I think the value of not having unused variables around outweighs the possible friction of the for i in range(N) cases. In fact, I slightly prefer the use of _ in that case because we're explicitly signaling that we are looping over something but aren't actually using any of the values, which is a (totally valid) but slightly odd thing to do

Let's go with this and we can always go back to ignoring B007 is it turns out to be painful for developers

@jrbourbeau jrbourbeau merged commit 4b89e26 into dask:main Aug 1, 2022
gjoseph92 pushed a commit to gjoseph92/distributed that referenced this pull request Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants