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

Rule useless-else-on-loop does not account for break statements in nested for-loops #386

Closed
3 tasks done
ruancomelli opened this issue Aug 30, 2023 · 2 comments
Closed
3 tasks done
Assignees
Labels
bug Something isn't working

Comments

@ruancomelli
Copy link
Contributor

ruancomelli commented Aug 30, 2023

Checklist

Description

The rule useless-else-on-loop should NOT trigger in the following snippet, but it does:

for thing in things:
    for other_thing in other_things:
        pass  # inner body
    else:
        break
else:
    explode_computer()

rewriting it as

for thing in things:
    for other_thing in other_things:
        pass  # inner body
    else:
        break
explode_computer()

Debug Information

Sourcery Version: 1.8.0

Additional Information

A user reported this bug to our e-mail support.

@ruancomelli ruancomelli added the bug Something isn't working label Aug 30, 2023
@ruancomelli ruancomelli self-assigned this Aug 30, 2023
@ruancomelli
Copy link
Contributor Author

Additionally, the message "If else clause is always executed move code to same level as loop" is wrong.

@ruancomelli
Copy link
Contributor Author

This was fixed by v1.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant