-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
False positive B023 errors are quite common with filter
, reduce
, key=
, return
and map
. For instance, this code
unsorted_things = [(["foo", "bar"], 0), (["foobar", "barfoo"], 4), (["baz", "foo", "moo"], 1)]
for unsorted_thing, letter in unsorted_things:
unsorted_thing.sort(key=lambda x: (x[letter], len(x)))
is fine, but it currently gets flagged as B023.
This was raised in Flake8 Bugbear in issue 303 (and 305) and fixed in 22.10.27.
Ignoring these does cause some false negatives, for instance if the filter
or map
is not evaluated before the next iteration, but this was deemed acceptable in the Bugbear issue.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working