Skip to content

B038 false positive in 24.1.15 + 24.1.16 #451

@mikaelarguedas

Description

@mikaelarguedas

First of all thanks for this new B038 new rule, it's a great addition!

Using flake8-bugbear 24.1.15

The following code is flagged.

some_list = [1, 2, 3]
for elem in some_list:
    print(elem)
    if elem == 2:
        found_idx = some_list.index(elem)  # should not error
        break

Although a method of some_list is called I believe this doesn't have any effect on the mutable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions