Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Require len() comparison check to only operate within if statements #32

Merged
merged 1 commit into from
Oct 2, 2022

Conversation

dosisod
Copy link
Owner

@dosisod dosisod commented Oct 2, 2022

Previously, this check picked up on cases which might cause a different value or type to be returned if the suggestion was blindly applied. The assumption was that you would be doing this in a boolean context, such as an if block, which would handle the truthy value correctly. Now this check only checks code inside of an if statement (including match guards, "if" sections of list generators, and so on).

Closes #31

Previously, this check picked up on cases which might cause a different value
or type to be returned if the suggestion was blindly applied. The assumption
was that you would be doing this in a boolean context, such as an `if` block,
which would handle the truthy value correctly. Now this check only checks code
inside of an `if` statement (including match guards, "if" sections of list
generators, and so on).
@dosisod dosisod self-assigned this Oct 2, 2022
@dosisod dosisod merged commit 6068e2e into master Oct 2, 2022
@dosisod dosisod deleted the len-cmp-false-positive branch October 2, 2022 03:23
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect len(x) > 0 suggestion
1 participant