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

B007 Loop control variable '_' not used within loop body #13921

Open
montanarograziano opened this issue Oct 25, 2024 · 1 comment
Open

B007 Loop control variable '_' not used within loop body #13921

montanarograziano opened this issue Oct 25, 2024 · 1 comment

Comments

@montanarograziano
Copy link

Hi, I don't know if this is an intended behaviour or not, but I'm having troubles understanding why a snippet like the following is highlighted as B007

for _ in range(10)
    print("hello")

From the doc, any variable prefixed with _ should be safe. Is there anything I'm doing wrong?
I know the example is (way too) trivial, but a more realistic use-case would be cycling through rows in a Pandas DataFrame with iterrows() but without using the index.
Thanks for the help!

@autinerd
Copy link
Contributor

Do you have some context where it gets flagged?

When testing here https://play.ruff.rs/56729c12-30db-43e0-955c-2e82ac2c4ece, it shows no violation.

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

No branches or pull requests

2 participants