Skip to content

Rule: Flake8-bugbear B038 " detect changes to iterable object of loop" #9511

@mimre25

Description

@mimre25

I've added a new rule to flake8-bugbear.

In brief, the rule detects bugs like the following:

some_list = [1,2,3]
for i in some_list:
  if i % 2 == 0:
    some_list.remove(i)
  print(i)

(More context at github.com/PyCQA/flake8-bugbear/issues/445)

I'd be happy to contribute if its desired to implement this rule in ruff as well 🙂

Metadata

Metadata

Assignees

Labels

acceptedReady for implementationruleImplementing or modifying a lint rule

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions