-
Notifications
You must be signed in to change notification settings - Fork 108
Closed
Description
having the following code;
mylist = list(range(5))
for item in mylist:
if item == 2:
mylist.remove(item) # <- badly detects B038 here
break
bugbear badly detects B038.
Sample: https://doc.wikimedia.org/pywikibot/master/_modules/proofreadpage.html#ProofreadPage
in index property (search for def index
). As B038 is descibed as Found a mutation of a mutable loop iterable inside the loop body. Changes to the iterable of a loop such as calls to list.remove() or via del can cause unintended bugs. This rule should be an optionated warning instead of a general rule.
Metadata
Metadata
Assignees
Labels
No labels