[flake8-bugbear] Avoid false positive for usage after continue (B031)#10539
Merged
charliermarsh merged 6 commits intoastral-sh:mainfrom Mar 25, 2024
Merged
[flake8-bugbear] Avoid false positive for usage after continue (B031)#10539charliermarsh merged 6 commits intoastral-sh:mainfrom
flake8-bugbear] Avoid false positive for usage after continue (B031)#10539charliermarsh merged 6 commits intoastral-sh:mainfrom
Conversation
Contributor
|
flake8-bugbear] Fix usage count algorithm (B031)flake8-bugbear] Avoid false positive for usage after continue (B031)
Member
|
I don't think this is the correct solution as it will not work for nested for _, group in itertools.groupby(...):
use_group(group)
for _ in range(5):
use_group(group) # B031
continue
use_group(group) # B031This PR stops highlighting the second |
Member
|
@dhruvmanila - It seems like we're fixing a common false positive but introducing a less common false negative, so it seems like the right tradeoff, unless you disagree? Feel free to file an issue if so. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#10337
I've fixed the code to count usage of variable.
Usage count inside the block is reset when there is a following statement.
Test Plan
Add test case.