PyCQA / flake8-bugbear

A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.
MIT License
1.05k stars 103 forks source link

include tuples in b018 useless-statement check #432

Closed r-downing closed 7 months ago

r-downing commented 7 months ago

I was looking for something to detect useless tuple statements, noticed this had a useless-statement check but didn't include tuples. Any reason for that? Otherwise, figured we could add it?

r-downing commented 7 months ago

Something else to note here - a dangling comma after a single thing (e.g. a function call) will turn it into a tuple, which would get flagged as a useless statement:

print("abc")  # this is fine
print("abc"),  # the comma essentially makes this a tuple (None,) so this would be flagged as a useless expression.

^ wondering if this might be confusing and should be labelled a little differently? Or even as separate error? E.g. useless tuple expression - suggest removing the comma