-
Notifications
You must be signed in to change notification settings - Fork 103
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
Detect unintended comma at the end of expression #35
Comments
That would be neat, indeed. Sadly, it's not trivial since our AST doesn't include this information. |
It is possible, though, since flake8 can give access to the raw source, and then can use Python's parser module to get a parse tree and work on that. |
I'm only worried about the additional overhead for just this one check. lib2to3 is in Python so it's going to slow down Bugbear a bit. We can do it and measure how bad that slowdown is but I have a feeling this is a better job for Black to always insert parentheses around single-element tuples to make this obvious. |
Not to deter adding this to bugbear, but flake8_tuple finds unintended tuples. |
If you use http://github.com/ambv/black/, it will helpfully wrap one-tuples in parentheses to make this more obvious. So if this wasn't intentional, it will be easier to spot. |
https://pypi.org/project/flake8-commas/ is another option. |
I would be great to have a rule that will detect cases such this:
As it is most likely a typo.
If someone wants a tuple, the preferred form would be
(item,)
.The text was updated successfully, but these errors were encountered: