Skip to content

False positive B023 with loop's local variable #402

@jamesbraza

Description

@jamesbraza
def some_fn(*_) -> None:
    ...


for _ in range(1):
    foo = 0
    some_fn(lambda: foo)

Since foo is a local variable in the loop, B023 shouldn't happen here (unless I am mistaken about something).

Running flake8==6.0.0 with flake8-bugbear==23.7.10 on this:

> flake8 a.py
a.py:7:21: B023 Function definition does not bind loop variable 'foo'.

I think this relates to #269 or #380.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions