-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some B023 false alarms #303
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - thanks @jakkdl!
cc @cooperlees to merge?
Thanks. Lots going on here I don't get but I'll trust you two! Tests look good. |
In short, there was enough chatter in that thread to make it clear the false-alarm rate was unacceptably high, and if we miss some real alarms that's basically just the natural downside of minimally-resourced open source projects! Better to catch most bugs without annoying people than have a tool that nobody uses... |
This is based on the upstream work in PyCQA/flake8-bugbear#303 and https://github.com/PyCQA/flake8-bugbear/pull/305/files. Resolves #1686.
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.