Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Picking up from main...Zac-HD:flake8-bugbear:B023-false-alarms
Partially fixes #269
Fixes some common false alarms where a function is immediately consumed, as an argument to
filter
orreduce
, as a keyword argument tokey=
and as a return value.TODO: I'm not sure how to handle more complex
return
cases, see the last test cases inb023.py
.I'm also not sure if this solution is too generous, it currently marks all direct child nodes to calls to
filter
&reduce
as safe - but @Zac-HD's comment implies it should maybe be stricter:I'm not super read up on the problem and didn't take time to fully understand all comments with false alarms in the original issue, so would love some eyes on this. But it fixes all test cases @Zac-HD added at least.