-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[bug?] B018 useless-expression
does not work
#3453
Comments
I think this is consistent with flake8-bugbear although I'm not sure why their rule is limited to those cases. |
I'm guessing they got rid of strings to avoid false positives with docstrings (https://github.com/PyCQA/flake8-bugbear/pull/209/files). I'm guessing they don't detect function calls since it's not really possible (with current information) to know whether a function call is effect-ful or pure. We could definitely detect binary operations though. |
In general I think we can improve this even if it deviates a bit from bugbear. |
I was actually unable to get this rule to trigger at all-- do you have an example of something that triggers it? Like,
Yeah, the expected behavior is not to detect a straight function call, but when it's followed by attribute access (as in my example) then I would think it should be detected. FWIW that's pylint's behavior. |
Prior to my open PR, the rule was only enforced in function and class bodies. I think this was consistent with bugbear but has since changed, so it’s reflected in the PR. |
Ah nice, somehow my eyes glossed over the PR notification. Thx for addressing. |
All good, that PR still doesn't include the |
None of the following trigger
B018
useless-expression
for me, when I would expect them all to:I might be missing something about what this rule is supposed to do though.
The text was updated successfully, but these errors were encountered: